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));     }); }); 

jsfiddle


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -