jQuery :gt selector with relative indexing -


i have <dl> list containing multiple <dd><ol>...</ol></dd> lists, each number of <li> elements. i'm trying select first 2 elements of each <ol> list.

i can achieve using

$("dl dd ol").each(function(){     $elems = $("li:gt(2)",$(this)); }); 

i'm curious, possible perform same operation without using $.each (i.e. using selectors)? i've tried $("dl dd ol > li:gt(2)") seems :gt not index relatively parent. there, currently, way using selectors?

jsfiddle

you can use find method:

$("dl dd ol").find("li:gt(2)").css('color','#f00'); 

http://jsfiddle.net/x28kb/


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -