Possible Duplicate:
Find out if radio button is checked with JQuery?
Hi, i want to make a div appear with jquery when one of 3 radio buttons is pressed..
I have 3 radio buttons, image video and sound, when the user clicks image, a div will appear.
how can i use jquery for this. I know how to do the div appearing part, just not the checking if the specific radio button is checked.
Bascially, how do i check if a specific radio is checked.
Thanks
if($('#radioButton').is(':checked')){
//radio button with id 'radioButton' is selected
//your logic here
} else {
//radio button is not selected
//your logic here
}
You can use
$('#radioButton').get(0).checked
if($('#radioButton1').attr('checked')) {
// show div 1, hide div 2 and div 3
} else {
if($('#radioButton2').attr('checked')) {
// show div 2, hide div 1 and div 3
} else {
if($('#radioButton3').attr('checked')) {
// show div 3, hide div 1 and div 2
}
}
}
精彩评论