I have two radio buttons that are YES (value=1) and NO (value=0), I’m using the following code to show a hidden division when you click on YES:
$("#regaddress").change(function(){
if ($(this).val() == "1" ) {
$("#registeredaddress").slideDown("fast"); //Slide Down Effect
} else {
$("#registeredaddress").slideUp("fast"); //Slide Up Effect
}
});
Code for Radio Buttons:
<input name="regaddress" id="regaddress" type="radio" value="1">Yes
<input name="regaddress" id="regaddress" type="radio" value="0" checked> No
What I need is the code to hide that division when you click NO. Should be a simple answer for some of you, but personally feel like banging my head against a wall this afternoon trying to work out how to hide it!
That’s easy enough, because you posted no
idornameattributes in your original question, I’ve abstracted it out to the following:html
jQuery
Demo of the above posted at JS Fiddle.
Amended slightly to take into account the
slideUp()andslideDown()usage:Demo at JS Fiddle.
Final edit to take into account your
idandnameattributes:Demo at JS Fiddle