I've got a problem with my code. I can detect the Enter key press in an input text element (or whatever it's called) but I only get to see the result briefly and then it disappears.
So my question is, why is this happening?
Thanks.
So my question is, why is this happening?
Thanks.
HTML:
<!DOCTYPE html>
<html>
<body>
<style>
#myresult
{border: 1px solid;min-height: 100px;width: 500px;text-align: left;}
</style>
<form id="myform">
<input id="myinput" type="text" onkeypress="clickPress(event)">
</form>
<script>
function clickPress(event) {
if (event.key == "Enter") {
document.getElementById("myresult").innerHTML = "You pressed the Enter key."
}
}
</script>
<br>
<p id="myresult" ></p>
</body>
</html>