[jQuery] Re: selecting li - beginner learning jquery

2009-04-16 Thread soni2926

thank you!


[jQuery] Re: selecting li - beginner learning jquery

2009-04-15 Thread Karl Swedberg

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=css1CSS1/a
/li
li
a href=css2CSS2/a
/li
li
a href=css3CSS3/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