0

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

Community
  • 1
  • 1
nmyster
  • 454
  • 1
  • 7
  • 20

3 Answers3

3
if($('#radioButton').is(':checked')){
    //radio button with id 'radioButton' is selected
    //your logic here
} else {
   //radio button is not selected
   //your logic here
}
no.good.at.coding
  • 20,221
  • 2
  • 60
  • 51
0

You can use

$('#radioButton').get(0).checked
Aliostad
  • 80,612
  • 21
  • 160
  • 208
0
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
        }
    }
}