Is there a way to modify this function so that when the heading is changed successfully, a "Change Back!" button appears? And then, with a click on the button, the heading is reset and the button disappears again.
function changer () {
var textArea = document.getElementById("text_box").value;
if (textArea.length === 0) {
alert("Please enter a value.");
return;
}
var heading = document.getElementById("heading");
heading.innerHTML = textArea;
}
#change_back {
display: none;
}
<!-- HTML -->
<h1 id="heading">This is a heading</h1>
<button id="change_back">Change Back!</button>
<input type="text" id="text_box">
<input type="submit" onclick="changer()">