Check whether specific radio button is checked

后端 未结 7 1076
忘掉有多难
忘掉有多难 2020-12-14 01:10

I\'m having trouble after looking at the jQuery docs. I\'m just trying to return true/false in one my my jquery methods depending on the check of a certain radiobutton and

7条回答
  •  醉酒成梦
    2020-12-14 01:26

    I think you're using the wrong approach. You should set the value attribute of your input elements. Check the docs for .val() for examples of setting and returning the .val() of input elements.

    ie.

    
    
    return $('input:radio[name=testGroup]:checked').val() == 'test2';
    

提交回复
热议问题