Search code examples
domformsdhtml

Client code: Finding which radio button is checked


In Javascript code on the browser, given the name of a group of radio buttons, is there a way to directly find out which button is checked without iterating through each button one by one to check its checked property?


Solution

  • Yes with jQuery. If the name of the group is state, then:

    $("[name=state]:checked").val()