count of selected radio buttons in jquery

后端 未结 3 1567
猫巷女王i
猫巷女王i 2021-02-20 06:38

suppose I have groups of radio buttons like so:

 
相关标签:
3条回答
  • 2021-02-20 07:16

    You could do:

     var numberOfCheckedRadio = $('input:radio:checked').length
     //this gives you the total of checked radio buttons on the page
    
    0 讨论(0)
  • 2021-02-20 07:22

    To check for only those specific groups:

    $(':radio[name="rdQueen"]:checked, :radio[name="rdFruit"]:checked').length;
    

    Example: http://jsfiddle.net/AlienWebguy/HzfKq/

    0 讨论(0)
  • 2021-02-20 07:25

    Use the checked-selector[docs] to get the ones that are checked, and the length[docs] property to find out how many there were.

    alert( $('input:radio:checked').length );
    
    0 讨论(0)
提交回复
热议问题