-2

Ok, so I'm using wordpress contact form 7 and I added some radiobuttons there. The code looks like this

[radio radio-681 id:radio1 "1" "2" "3"]

When I'm using dropdowns in that form they look like this

[select* three id:three include_blank class:contactForm "2" "3" "4"]

And I can call that in jquery like this

$('#three').change(function() {
    if ($("#three").val() == "3") {
        //do something
    }
});

Now my question is, how can I check if a radiobutton is checked?

EDIT: Thank you all for your fast response it works now.

David Gard
  • 11,225
  • 36
  • 115
  • 227
TheDawn
  • 3
  • 2

4 Answers4

0

Try this:

if($('#radio_button').is(':checked'))
{
 // do your stuff
}
Linga
  • 10,379
  • 10
  • 52
  • 104
0

Do this:

if($("#three").attr('checked') === 'checked' )
{
    //Do something
}

Hope this helps.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
0
$('#yourRadioButton').is(':checked')

or

$('.setOfRadioButtons:checked').val()
MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
lazy.lizard
  • 834
  • 6
  • 11
0

Something like this:

if($('#three').is(':checked')) { alert("it's checked"); }
saifur
  • 637
  • 4
  • 17