代码需要做的是保存信息,但事实并非如此! 请帮助解决这个问题
function signin() {
var y = document.getElementById("email2");
var x = document.getElementById("myInput");
if (y == email2 && x == myInput) {
window.open("account.html");
} else {
window.open('sign in.html');
}
}

<form>
<h1>Email</h1>
<input type="email" id="email2" required><br><br>
<h1>Password</h1>
<input type="password" id="myInput">
<input type="checkbox" onclick="myFunction()">Show Password<br><br>
</form>
<input type="Submit" onclick="signin()">
&#13;
答案 0 :(得分:0)
我不知道这到底是为了保存信息,但无论如何:
您的代码不正确:
email2
MyInput
此外,您无法将答案存储在任何地方,这可能是其无法存储任何内容的另一个原因。
您需要将其分配到存储位置,如localStorage
等。定义变量email2
和MyInput
。
此外,变量x
和y
正在获取元素,而不是它们的值,我怀疑您需要的元素不仅仅是元素
或者如果您不想阅读本文并且只是使用现有软件包,或者直接浏览浏览器account.html
,则无需使用所有愚蠢的代码。
更好的做法 @ADyson 哪个IMO是最好的主意(在评论中给出)