The question on all of this is usage - and I don't know how clear it was stated.
The selectors everyone has put up are valid, but not necessarily for the usage. <<I have provlem with selecting a first link in code below. Can you help me how how it should look like jQuery code and also for case, if Home will not be a link, so "Rules" will be a first link.>> So the issue is to remove only the first link. $('#menu li:first a) will only select the anchor inside first list item. Perfect until you put home inside that with no link. Then nothing matches that criteria. $('#menu li a:first') matches up to the first anchor tag inside a li. http://test.learningjquery.com/selector-bug.html Proves the theory. If you did a selector of 'p' it would affect ALL of them, right? So there are 7 anchors in the first position of an li, and 0 in the second. Jquery 1.3 didn't create a bug - it fixed a selector problem. The only true selector is to use $('#menu a:first'). It will select the first anchor and only the first anchor. It all just problem with sloppy selectors in the past. They cleaned it up and got it right. I would suggest we make the adjustments. On Jan 17, 4:19 pm, "Nic Luciano" <nic.luci...@gmail.com> wrote: > Ah, Karl, I see the issue now. I was also confused with the original usage > since the discussion was about :first but he was using :first-child. So let > me ask, in your test, li a:first should only return one element (as per > docs, :first should always only return one element), correct? And > first-child would be what I originally expected (returning 7 links)? > > Can't believe I overlooked that- I stand corrected :D > > On Sat, Jan 17, 2009 at 4:13 PM, Ricardo Tomasi <ricardob...@gmail.com>wrote: > > > > > I know this isn't the dev list, but I'm curious about how come these > > bugs weren't caught by the test suite? > > > On Jan 17, 6:50 pm, Karl Swedberg <k...@englishrules.com> wrote: > > > Nic, > > > Actually, it is a bug, at least in the sense that the results are > > > different from those of any previous version of jQuery. > > > > It isn't just about :first, though. It has to do with multiple- > > > descendant selectors in general. I've provided a test case athttp:// > > test.learningjquery.com/selector-bug.html > > > with side-by-side comparison of 1.2.6 and 1.3, showing the number of > > > matches (and I also posted an update to the ticket). > > > > --Karl > > > > ____________ > > > Karl Swedbergwww.englishrules.comwww.learningjquery.com > > > > On Jan 17, 2009, at 3:39 PM, Nic Luciano wrote: > > > > > That's true, but that's exactly how it's supposed to function. > > > > > On Sat, Jan 17, 2009 at 3:35 PM, jQuery Lover > > > > <ilovejqu...@gmail.com> wrote: > > > > > No he is not! > > > > > Suppose you have this scenario: > > > > > <div id="container"> > > > > <ul id="menu"> > > > > <li>Home</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> > > > > > $('#menu li:first a').remove() - will do nothing here, since first li > > > > has no anchor in it ! > > > > > ---- > > > > Read jQuery HowTo Resource - http://jquery-howto.blogspot.com > > > > > On Sun, Jan 18, 2009 at 1:28 AM, Charlie22 <ch...@post.cz> wrote: > > > > > > Well, you are right, thx for explanation. Now it is clear!! > > > > > > On 17 Led, 21:04, Pedram <pedram...@gmail.com> wrote: > > > > >> hi Guys , I know what should you do , > > > > >> $('#menu li:first a').remove() > > > > >> this is the code you need , jquery has no problem when you use this > > > > >> code $('#menu li a:first').remove(); the selector checks each li > > > > and > > > > >> removes the <a> so all of the links will be removed so in your case > > > > >> your code should look like this $('#menu li:first a').remove(); > > > > the > > > > >> selector selects the first li and removes the <a> > > > > >> that set, > > > > >> I am just following john Resig in twitter it seems he is going to > > > > >> release jquery 1.3.1 maybe he found some little bugs.