Skip to main content

Bug Tracker

Side navigation

#8361 closed bug (duplicate)

Opened February 23, 2011 11:39AM UTC

Closed February 23, 2011 11:50AM UTC

Last modified March 02, 2011 04:48AM UTC

ID selector not working for ID having colon or period

Reported by: anonymous Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

jquery ID selector is not selecting html elements which has id having colons (:) or periods (.)

As per w3c http://www.w3.org/TR/html4/types.html#h-6.2 this should be allowed.

Try this :

<div id="abc:xyz">123</div>

<script>

alert($('#abc:xyz').html());

alert(document.getElementById('abc:xyz').innerHTML);

</script>

Attachments (0)
Change History (4)

Changed February 23, 2011 11:42AM UTC by rafiahmad@gmail.com comment:1

The jsFiddle url is:

http://jsfiddle.net/wjwRb/

Changed February 23, 2011 11:50AM UTC by jitter comment:2

component: unfiledselector
priority: undecidedlow
resolution: → duplicate
status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a test case!

Your selector is invalid, the documentation is pretty clear about these kind of selectors:

http://api.jquery.com/category/selectors/

If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;?@[\\]^`{|}~ ) as a literal part of a name, you must escape the character with two backslashes

Check this working test case

Changed February 23, 2011 11:50AM UTC by jitter comment:3

Duplicate of #5241.

Changed March 02, 2011 04:48AM UTC by mharen@gmail.com comment:4

Just in case anyone's going crazy like me, this DID work in before 1.5. I do not object to this ticket being closed for the reason cited--I just want to put others at ease who have discovered the change in behavior as I have.