Answers for "javascript how to change the text of a button after a click"

2

javascript change button text onclick

<!DOCTYPE html>
<html>
<body>

<button id="demo" onclick="myFunction()">Click me to change my HTML content (innerHTML).</button>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Paragraph changed!";
}
</script>

</body>
</html>
Posted by: Guest on September-14-2020
1

how to change the text in a button on onclick

var btn = document.getElementById("mybtn");
btn.value = 'my value'; // will just add a hidden value
btn.innerHTML = 'my text';
Posted by: Guest on October-21-2020

Code answers related to "javascript how to change the text of a button after a click"

Browse Popular Code Answers by Language