html lists - Create string of nth li's in jQuery -



html lists - Create string of nth li's in jQuery -

how create string of each 3rd li, resulting in

black,red,blue

from this:

<div id="container"> <ul> <li>shirt</li> <li>x-large</li> <li>black</li> <li>9.99</li> </ul> <ul> <li>pants</li> <li>large</li> <li>red</li> <li>19.99</li> </ul> <ul> <li>shoes</li> <li>medium</li> <li>blue</li> <li>9.99</li> </ul> </div>

try below,

$(function () { var result = []; $('#container ul').find('li:eq(2)').each(function () { result.push($(this).text()); }); result.join(); });

demo: http://jsfiddle.net/bxjbh/

jquery html-lists css-selectors

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -