How to check radio button is checked using JQuery?

后端 未结 8 735
猫巷女王i
猫巷女王i 2020-12-24 07:20

I have two radio buttons in one group, I want to check the radio button is checked or not using JQuery, How ?

相关标签:
8条回答
  • 2020-12-24 07:42

    Try this:

    var count =0;
    
    $('input[name="radioGroup"]').each(function(){
      if (this.checked)
        {
          count++;
        }
    });
    

    If any of radio button checked than you will get 1

    0 讨论(0)
  • 2020-12-24 07:47

    This is best practice

    $("input[name='radioGroup']:checked").val()
    
    0 讨论(0)
提交回复
热议问题