Ticket #7191 (closed bug: invalid)
Get just the first radio group value
| Reported by: | webskate | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.4.3 |
| Component: | unfiled | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
when i try to get the value of two radio checked from two radio group diferents I always get the value of the first radio checked, I've tried with jqyery 1.4.2 and 1.3.2 and got this error but with jquery 1.1.2 works fine.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script language="JavaScript" type="text/JavaScript" >
function pegarValores(){
alert($('input[@name=teste_radio]:checked').val());
alert($('input[@name=teste_radio_2]:checked').val());
}
</script>
</head>
<body>
<form id="testeForm" name="testeForm">
abc <input type="radio" name="teste_radio" value="1"/>
def <input type="radio" name="teste_radio" value="2"/>
ghi <input type="radio" name="teste_radio" value="3"/><br/>
jkl <input type="radio" name="teste_radio_2" value="4"/>
mno <input type="radio" name="teste_radio_2" value="5"/>
pqr <input type="radio" name="teste_radio_2" value="6"/>
<input type="button" onclick="pegarValores()" value="pegar valores"/>
</form>
</body>
</html>
Change History
comment:2 Changed 3 years ago by jitter
From http://api.jquery.com/category/selectors/attribute-selectors/
Note: In jQuery 1.3 [@attr] style selectors were removed (they were previously deprecated in jQuery 1.2). Simply remove the “@” symbol from your selectors in order to make them work again.
So using [@attr] is a no go since jQuery 1.2. By simply removing the @ from your selectors everything works fine for me
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for the report, but this is not a bug. jQuery has not supported XPath selectors for a very long time. Please read the changelogs and documentation. In the future, please use the jQuery Forum for support requests.