Hey I am looking for a very simply jQuery code that displays a hidden div when a certain radio button is selected, and hides that div if that radio button is “deselected”.
I figured it out how to make it work with checkboxes but I don’t know why it won’t work with radio buttons as well.
Here is the code which works fine with checkboxes:
$("#radio-id").click(function(){
// If checked
if ($("#radio-id").is(":checked")) {
//show the hidden div
$("#div-id").show("slide");
} else {
//otherwise, hide it
$("#div-id").hide("slide");
}
});
It seems you’ve made a syntax error. I don’t think divs can be checked.