I’m creating a page with content on it initially set as hidden. At the top of the page there’s a form asking for a password. Once entered, the <div>
should display as block
, but I cannot seem to connect the two functions.
document.querySelector("#pwd").onsubmit(function() {
if (document.querySelector('#pwd').value == "test123") {
document.getElementById("#content").style.display = "block";
}
});
#content {
height: 250px;
width: 250px;
background-color: red;
margin-top: 20px;
display: none;
}
<form>
Enter the password to see the content:
<input id="pwd" type="password" name="pwd" />
</form>
<div id="content">
Testing Content
</div>