This is my code:
$('#opentab').click(function() {
$('.opentabdiv').toggle();
$(this).toggleClass("closetab opentab");
return false;
});
Basically there is a DIV (or link I should say) called #opentab" that when it is clicked, another DIV called .opentabdiv will open, and the class of #opentab will change.
Now my problem comes when I put a checkbox in the #opentab DIV. I want the checkbox to be checked when the .opentabdiv is open, and empty when it is closed.
This is the HTML of the checkbox inside the #opentab DIV:
<a href="#" id="opentab" class="closetab"><input type="checkbox" id="yesactive" name="yesactive" value="yes"> OPEN</a>
Does anyone know the jquery to make the checkbox change? I've tried some codes I found but it only works once. If I close the DIV, it does not untick.
The checkbox should be unticked on default because the .opentabdiv DIV is closed.