Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery .each through Divs inside another Div

I currently have the following html:

Apologies for edit, I was not paying attention when i wrote this.

 <div class ="left">
    <div>1</div>
    <div>2</div>
    <div>3</div>
</div>

I am using the JQuery .each command to iterate through each div using $('div').each. Although I only want to iterate through the divs inside the div with the class name 'left'.

I have tried using $('.left > div').each but it did not work.

Any help appreciated.

like image 295
James Mclaren Avatar asked Jul 18 '12 14:07

James Mclaren


1 Answers

Is this what you're lookng for?

$('div.left>div').each(function(){ /* do stuff */ });

Fiddle: http://jsfiddle.net/MLnBY/

like image 114
Paul Fleming Avatar answered Oct 04 '22 03:10

Paul Fleming