Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#1041 closed bug (wontfix)

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:


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]").

Change History (2)

comment:1 Changed 16 years ago by aheimlich

Brackets are not legal characters in IDs, so I'm surprised that works at all.


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)

comment:2 Changed 16 years ago by john

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.