Side navigation
#6379 closed bug (worksforme)
Opened March 31, 2010 01:28AM UTC
Closed October 03, 2010 12:41AM UTC
Unable to use the attibute selector with a numeric attribute
| Reported by: | redlava | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.4.3 |
| Component: | selector | Version: | 1.4.2 |
| Keywords: | attribute selector numeric | Cc: | |
| Blocked by: | Blocking: |
Description
I attempted to use the following selector but I was unable to select an object with a numeric attribute such as "1"
$('input[input.radio[value=1]]')
If I prefix the value attribute and the selector with a character it works correctly. Do numeric attributes need to be escaped in some way or am I missing something? I am aware that some attributes must not start with a number be I don't believe this is true for the input value attribute.
Attachments (0)
Change History (3)
Changed March 31, 2010 01:44AM UTC by comment:1
Changed September 08, 2010 01:49PM UTC by comment:2
it works properly
<html>
<head>
<script language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script>
$(document).ready(function() {
$('input[value=a]').css('background','red');
$('input[value=1]').css('background','green');
});
</script>
</head>
<body>
<input value="a" type="text"/>
<input value="1" type="text"/>
</body>
</html>
Changed October 03, 2010 12:41AM UTC by comment:3
| priority: | → undecided |
|---|---|
| resolution: | → worksforme |
| status: | new → closed |
It would appear that in your original example (as well as in the follow up from a few months ago) you were using incorrect selectors to try selecting both an input with a numeric value as well as an input (of type radio) with a numeric value.
In order to select a radio input element simply use input:radio and you'll be able to do what you're attempting. Similar to what dfens has previously posted, doing this effectively combined with the :radio selector should solve the problem:
input:radio[value=1] for example
Please see here for a Live test case http://jsfiddle.net/6ar5c/
My previous example was actually incorrect, it should have read:
$('input.radio[value=1]')