I want to display a div if a certain radio button in a form is selected, but hide that div if any other radio button in the form is selected, using jquery.
This is the code I have that isn’t working:
$("select").change(function(){
if($("#radio1").is(":selected")){
$("#grid_9 omega").slideDown("slow");
} else { $("#grid_9 omega").slideUp("slow"); }
});
where the id for the radio button I want to have display the div “gid_9 omega” is “radio1”.
Thanks for your help!
I took the liberty of thinking that maybe omega was a class that you were referring to incorrectly.
First, there is no select here so that is not going to work for you. You need to test on all
input[type=radio].Next, radio button attribute for selected is actually
checked=checked, so you need to test if the one you want to be checked is checked. If not, do nothing, if so, show your div.A JSFiddle
Using a similar html structure to this below:
your js would look like this: