#12893 closed bug (notabug)
.find using an id selector only returns one element
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Using a '#id' selector in a .find only returns the first element, in 1.7 it return all matching.
I know that it's not much of an identifier if there is more then one but !
Change History (4)
comment:1 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
comment:2 Changed 10 years ago by
Well, it's not invalid to have the same ID value used multiple times in a document (unfortunately this is by spec), but we don't support it because then we can't use shortcut methods like getElementById
when parsing the selector. Just don't do it.
Side note: Dave is right when he says the id cannot start with digits. It must be a valid javascript identifier.
comment:3 Changed 10 years ago by
From the spec:
The value must be unique amongst all the IDs in the element's home subtree and must contain at least one character.
comment:4 Changed 10 years ago by
Yea I take that back. Could have sworn the spec said the opposite. Oh well.
A document with multiple elements having the same ID value is invalid. This example takes it a step further and uses only digits for the ID value, which is invalid as well. If you're not sure what this means, please ask for help on the forum or StackOverflow.