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
Post a Comment