Hello together,
I am learning JavaScript at the moment and I cannot run a simple code. I do not know if there is a mistake or if I have to install something first!? Quite frustrating since I am at the very beginning.
My code is shown below. It is more or less exactly the code from a lesson I was recently doing, so it should be correct. I just wanted to do a first test to update a webpage by pressing a button. The page should present the username + "signed up" after entering the name and pressing the button. However, if I test it in my firefox it doesn't work. Does also not work in Edge. Is there a mistake in the code? I saved the file under test.html in case that's relevant.
I would appreciate your help!
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<input id="usernameInput" type="text" placeholder="username">
<button onclick="signUp()">Sign up</button>
<p id="message"></p>
<script type="text/javascript">
function signUp() {
var username = document.getElementsByID("usernameInput").value;
document.getElementsByID("message").innerHTML = username + " signed up";
}
</script>
</body>
</html>