How to get the text displayed on HTML button with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
<body>
 
<form>
<button id="buttonid" name="abcdefg" type="submit" value="Button Value">The Button</button>
</form>
 
<br />
 
<button onclick="GetButtonValue()">Get Button Display Text (innerHTML)</button>
 
<p id="pid"></p>
 
<script>
function GetButtonValue() {
  var val = document.getElementById("buttonid").innerHTML;
  document.getElementById("pid").innerHTML = val;
}
</script>
 
</body>
</html>

 



answered Jan 17, 2019 by avibootz

Related questions

2 answers 201 views
1 answer 301 views
1 answer 228 views
1 answer 221 views
1 answer 234 views
...