I have a button with a JavaScript event handler, trying to make a change in the document object model on click. It makes that change, but immediately reverts it; clicking the button causes the text to change, but only for an instant before changes back. Why is it changing back? How can I stop that happening?
var button_variable_name = document.getElementById("changeText");
button_variable_name.addEventListener("click", function() {
document.querySelector('#test').textContent="Replace the text";
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>blank</title>
</head>
<body>
<form>
<input type="text" id="a" />
<input type="text" id="b" />
<input type="text" id="c" />
<button id="changeText" > button </button>
</form>
<p id="test"> test text </p>
</body>
</html>