On Apr 15, 2009, at 4:31 PM, soni2926 wrote:
Hi, I'm trying to learn Jquery (reading Manning Jquery in Action) in the book there is this sample: <ul class="myList"> <li> <a href="http://jquery.com">jQuery supports</a> <ul> <li> <a href="css1">CSS1</a> </li> <li> <a href="css2">CSS2</a> </li> <li> <a href="css3">CSS3</a> </li> <li> Basic XPath </li> </ul> </li> <li> jQuery also supports <ul> <li> Custom selectors </li> <li> Form selectors </li> </ul> </li> </ul> how would i be able to select just the <li> that has the JQuery also Supports in it? i got this to grab it: ul.myList li:eq(5) just wondering if there is another way? thanks.
There are many other ways. Here are a few: $('.myList > li:last') $('.myList').children(':last') $('.myList > li:eq(1)') $('.myList li:has(li):eq(1)') $('li:contains(jQuery also supports)') $('.myList li:last').parents('li') $('.myList li:last').parent().parent() It really depends on what you're looking for. --Karl ____________ Karl Swedberg www.englishrules.com www.learningjquery.com