隐藏具有两个密码的DIV元素
我是新手,需要使用多个密码。如何使用多个密码
我不知道该如何改变。
#HIDDENDIV {
display: none;
}
#table td {
padding: 1em;
border: 1px solid black;
}
#table.show tr > *:nth-child(2) {
display: block;
}
<div id="passw">
<div>
(THE PASSWORD IS PASSWORD) <br />
Enter the password to proceed:
</div>
<div>
<input type="password" id="password" onkeydown="if (event.keyCode == 13) document.getElementById('button').click()" /> <!-- IMPORTANT! this part is so if you click enter, it works. -->
</div>
<div>
<br/>
<input id="button" type="button" value="Login" onclick="if (document.getElementById('password').value == 'PASSWORD') {
document.getElementById('table').classList.toggle('show'); document.getElementById('passw').style.display='none'; }
else { alert('Invalid Password!'); password.setSelectionRange(0, password.value.length); } " />
</div>
<!-- it will autoselect wrong input if wrong -->
<br /><br /><br />
</div>
<table id="table">
<tr>
<td>stuff</td>
<td id="HIDDENDIV" >hidden stuff</td>
</tr>
</table>
答案 0 :(得分:0)
//for multiple password
var passowrdField = document.getElementById('password').value;
function passsword(){
if (passowrdField == 'PASSWORD'|| passowrdField == 'Arindam' || passowrdField == 'Suman') {
document.getElementById('table').classList.toggle('show'); document.getElementById('passw').style.display='none'; }
else { alert('Invalid Password!'); password.setSelectionRange(0, password.value.length); }
}
#HIDDENDIV {
display: none;
}
#table td {
padding: 1em;
border: 1px solid black;
}
#table.show tr > *:nth-child(2) {
display: block;
}
<div id="passw">
<div>
(THE PASSWORD IS PASSWORD) <br />
Enter the password to proceed:
</div>
<div>
<input type="password" id="password" onkeydown="if (event.keyCode == 13) document.getElementById('button').click()" /> <!-- IMPORTANT! this part is so if you click enter, it works. -->
</div>
<div>
<br/>
<input id="button" type="button" value="Login" onclick="passsword()" />
</div>
<!-- it will autoselect wrong input if wrong -->
<br /><br /><br />
</div>
<table id="table">
<tr>
<td>stuff</td>
<td id="HIDDENDIV" >hidden stuff</td>
</tr>
</table>
您可以使用w3schools的||
运算符plese check or
运算符来使用多个密码