I'm trying to get the value of a radio button with $("input[@name=login]")
, but am getting "Uncaught Syntax error, unrecognized expression".
See http://jsfiddle.net/fwnUm/ and here's the code in full:
<!-- Radio buttons to choose signin/register -->
<fieldset data-role="controlgroup" data-theme="z" data-type="horizontal" >
<input type="radio" name="login" id="radio-signin" value="signin" checked="checked" />
<label for="radio-signin">Signin</label>
<input type="radio" name="login" id="radio-register" value="register" />
<label for="radio-register">Register</label>
</fieldset>
$(document).ready(function() {
$("input[@name=login]").change(function(){
alert($("input[@name=login]:checked").val());
});
});
XPath-like attribute selectors were removed in jQuery 1.3. (We're now on jQuery 1.6.)
Just remove the @
:
$("input[name='login']").change(function(){
alert($("input[name='login']:checked").val());
});
Note that quote marks are also required.
See the API reference for the attribute equals selector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With