Get Button Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Button


The Input Button object represents an HTML <button> element.

You can access an <button> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button id="myBtn" onclick="myFunction()" value="get the text that on the button">test</button>

<p id="demo"></p>

function myFunction() {// w w w .ja  v a  2  s .co  m
    var x = document.getElementById("myBtn").value;
    document.getElementById("demo").innerHTML = x;


Related Tutorials