lundi 16 novembre 2015

Changing CSS visibility with JavaScript if a checkbox has been checked

I think the title is descriptive enough, so I'm just gonna paste my code below:

http://ift.tt/1Oc7clc

If my (admittedly poor) understanding of JS is correct, the blue div should hide when the checkbox is checked. I've tried a lot of different syntax, but no luck so far. Can anyone help me here? Thanks in advance

html

<input type="checkbox" id="check">
<div id="box"></div>

css

#box {
      background: lightblue;
      width: 200px;
      height: 200px;
}

js

if (document.getElementById("check".checked = "true")) {
      document.getElementById("box").style.visibility = "hidden";
}




Aucun commentaire:

Enregistrer un commentaire