I'm currently learning the JS basics, and the sample code acts weird. When I press the button the two numbers from input "ar1" and "ar2" supposed to be added up, and displayed in the paragraph. For a moment I see the answer, but the webpage refreshes itself immediatly. What could cause it? Thanks for your answer!
...
<body>
<form>
<input type="number" name="ar1"></br>
<input type="number" name="ar2"></br>
<button>go</button>
</form>
<p id="osszeg">Here is the answer</p>
<script src="script.js"></script>
</body>
</html>
The script.js:
function osszead()
{
let ar1 = parseInt(document.querySelector("input[name=ar1]").value);
let ar2 = parseInt(document.querySelector("input[name=ar2]").value);
let ossz = ar1 + ar2;
document.querySelector("#osszeg").innerHTML = ossz;
}