When i write my code like bellow, the text in the input field appears in the p element for a second and then it vanishes. And when i remove the form tags the text stays in the p element. Why this happens?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
</head>
<body>
<form>
<input type="text" id="txbox" placeholder="enter your name here">
<button id="btn">click</button>
</form>
<p id="app"></p>
<script>
function put() {
var txt = document.getElementById('txbox').value;
document.getElementById('app').innerHTML= txt;
}
var mybtn = document.getElementById('btn');
mybtn.addEventListener("click", put);
</script>
</body>
</html>