So i'm trying to create a web page function, where you can type in text and it changes something on the page. I can use buttons that has pre-arranged text and it changes it, but when I use a form it changes the text for less than a second then reverts back to the original text. Would appreciate some help. Below is my html and js file.
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="CS_Site_Index.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script type="text/javascript" src="CS_Site_Index.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<p id="demo"> hi</p>
<button id="ButtonText"> Click Here To Change The Text</button>
<button id="ButtonText2"> Click Here To Change The Text Back</button>
<br>
<form>
Change The Text<br>
<input id="text1" type="text"><br>
<br>
<input id="ButtonTextSubmit" type="submit" value="Submit">
</form>
<script type="text/javascript" src="changetext.js"></script>
</body>
</html>
this is my js file
document.getElementById("ButtonText").addEventListener("click", function(){document.getElementById("demo").innerHTML = "Hello World";});
document.getElementById("ButtonText2").addEventListener("click", function(){document.getElementById("demo").innerHTML = "Hi";});
document.getElementById("ButtonTextSubmit").addEventListener("click", function(){document.getElementById("demo").innerHTML = document.getElementById("text1").value;});
Would appreciate the help thanks