change input text on button click css code example
Example 1: 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>
Example 2: javascript when button clicked different text appears
function show() {
var box = document.getElementById('box');
var displaySetting = myClock.style.display;
var showButton = document.getElementById('showButton');
if (displaySetting == 'block') {
myClock.style.display = 'none';
clockButton.innerHTML = 'Show box';
}
else {
myClock.style.display = 'block';
clockButton.innerHTML = 'Hide box';
}
}