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 if it's selected or not
I've tried several things but have not been able to get this right:
<input type="radio" runat="server" name="testGroup" id="test1" /><label for="<%=test1.ClientID %>" style="cursor:hand" runat="server">Test1</label>
<input type="radio" runat="server" name="testGroup" id="test2" /><label for="<%=test2.ClientID %>" style="cursor:hand" runat="server">Test2</label>
<input type="radio" runat="server" name="testGroup" id="test3" /> <label for="<%=test3.ClientID %>" style="cursor:hand">Test3</label>
and in my method I have this:
return $("input[@name='test2']:checked");
I'm getting an undefined on $("input[@name='test2']:checked");
UPDATED:
example:
<input type="radio" runat="server" name="radioGroup" id="payPalRadioButton" value="paypalSelected" />
this returns 'undefined' still:
$("input[@name=radioGroup]:checked").attr('payPalRadioButton');
If I try this, I get 'false' even if I select the radio button:
$('input:radio[name=radioGroup]:checked').val() == 'paypalSelected'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…