这是我正在使用的代码。
<script>
function login(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if(username == "Ethan" && password == "Horton"){
document.getElementById("test").innerHTML="Logged In: "Ethan"
}
else{
alert("Incorrect User/Pass")
}
}
</script>
<br />
Username: <input type="text" name="username" id = "username">
Password: <input type="password" name="password" id = "password">
<button type = "button" onclick = "login()">Login</button>
当我按下按钮时,不会调用该函数。(我对 JavaScript 有点陌生。)