javascript - jQuery get first children of element -
here html
<div class="start"> <div> <!-- --> <div></div> </div> <div></div> <!-- --> <div> <!-- --> <div> <div></div> </div> <div> <div>
i need collect selected div
, , can $('div[class="start"] > div')
, how in .each()
cycle, because i'm cycling on div[class="start"]'
.
$('div[class="start"]').each(function(){ dosomething($(this)); //this below want achieve $(this).children('> div').each(function(){ dosomethingelse($(this)); }); });
your code more or less correct instead of children() need use find()
$('div[class="start"]').each(function(){ dosomething($(this)); //this below want achieve $(this).find('> div').each(function(){ dosomethingelse($(this)); }); });
Comments
Post a Comment