Side navigation
#1041 closed bug (wontfix)
Opened March 11, 2007 07:59PM UTC
Closed March 12, 2007 07:58PM UTC
Last modified June 20, 2007 12:51AM UTC
jQuery support for IDs with square brackets
Reported by: | trucex | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.1.3 |
Component: | core | Version: | 1.1.2 |
Keywords: | selectors | Cc: | |
Blocked by: | Blocking: |
Description
After some toying with it, I've had to revert a lot of my value changing code to just straight DOM manipulation with getElementById instead of using jQuery :(
No error is thrown, but no change is made either, when I perform a statement like the following:
$("#myid[0]").html("Hello World!");
Everything works fine, however, if I use document.getElementById("myid[0]").
Brackets are not legal characters in IDs, so I'm surprised that works at all.
FYI:
The (ID) attribute's value must begin with a letter in the range A-Z or a-z and may be followed by letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). The value is case-sensitive.
Source: http://www.htmlhelp.com/reference/html40/attrs.html#id
Though for CSS selectors, colons (":") and periods (".") are not allowed because they have special meaning in CSS selector syntax (though there is talk about adding some kind of support for these within jQuery)