Side navigation
#4134 closed bug (invalid)
Opened February 12, 2009 11:15AM UTC
Closed February 14, 2009 01:04AM UTC
Last modified March 14, 2012 03:00PM UTC
Selectors with multiple identical id is not works
| Reported by: | shagren | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3.2 |
| Component: | unfiled | Version: | 1.3.1 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
Please look for next code
<div id="t">
<span id="t">
some content
</span>
</div>
<a href="#" onclick="javascript: alert($('div#t div#t').length); return false;">Click me</a>
I see empty result when click. With 1.2.6 - works good. With 1.3.1 and nightly build(r6170) works bad.
When id is not identical works good.
Attachments (0)
Change History (4)
Changed February 12, 2009 12:33PM UTC by comment:1
Changed February 12, 2009 11:58PM UTC by comment:2
| resolution: | → invalid |
|---|---|
| status: | new → closed |
Right, ID attributes need to be unique. If they are not the browser can do something unpredictable.
Changed February 13, 2009 03:26PM UTC by comment:3
| resolution: | invalid |
|---|---|
| status: | closed → reopened |
Yes, but it is works in 1.2.x. Then it can break old code.
Then need return old behavior or document changes somewhere.
Changed February 14, 2009 01:04AM UTC by comment:4
| resolution: | → invalid |
|---|---|
| status: | reopened → closed |
Sorry, but jQuery can't guarantee consistent behavior across browsers when the document is invalid, and duplicate id attributes are such a case.
Your test case returns 0 in both 1.2.6 and 1.3.1, which seems correct even if duplicate id attributes were allowed. There is no
div#tin the document that has a descendent
div#t!
If you feel this merits further discussion, please do not reopen the ticket; take it to the jQuery Dev group.
its no valid html to have several elements with an equal id..
id hast to be unique