Opened 14 years ago
Closed 14 years ago
#3903 closed bug (fixed)
:first selector selects all elements
Reported by: | Uzbekjon | Owned by: | john |
---|---|---|---|
Priority: | major | Milestone: | 1.3.1 |
Component: | selector | Version: | 1.3 |
Keywords: | :first, selector | Cc: | |
Blocked by: | Blocking: |
Description
Trying to remove first anchor in the following list removes all of them:
<div id="container">
<ul id="menu">
<li><a href="#">Home</a></li> <li><a href="#">Rules</a></li> <li><a href="#">Pilots</a></li> <li><a href="#">Briefing</a></li> <li><a href="#">IGC</a></li> <li><a href="#">Results</a></li> <li><a href="#">Forum</a></li>
</ul>
</div>
Removes all anchors. $('#menu li a:first').remove();
Change History (3)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Actually, it may be a bug, at least in the sense that the results are different from those of any prior jQuery version. It isn't just about :first, though. It has to do with multiple-descendant selectors in general. I've provided a test case at http://test.learningjquery.com/selector-bug.html with side-by-side comparison of 1.2.6 and 1.3, showing the number of matches.
comment:3 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Duplicate of #3873 (already fixed).
This is not a bug, as the selector is looking for the first anchor element within every list item. "#menu li:first a" is the correct selector.