Are you a student?<br>
    <input type = "radio" name = "student" value = "I am a student">Yes
    <input type = "radio" name = "student" value = "not a student">No
    <input type = "submit">

What if an if statement wants to check if value = "not a student" is checked? .

You can also get the value of the second name attribute. . .

  • Answer # 1

    JavaScript (jQuery)

    $('input [type = "radio"]'). click (function () {
      alert ($(this) .val ());


  • Answer # 2

        Are you a student?
        Yes     No     

    * Or instead of picking out what is checked
    If you just want to pick up the second value

        Are you a student?
        Yes     No     

Related articles