1

I have content loaded into a hidden iframe on a page and I'm wanting to loop through multiple elements on a page and get text using jquery.

Here is my current code:

$('#myiFrame').contents().find('div.air').each(function (index) {
       alert($(this).text());
     });

It only seems to find the one div with the class of 'air', although there is two divs on the page. How is my code wrong ?

Edit: I should say their are two 'div.air' on the page not under the same parent.

HTML it something like :

<section id="blah">
<div class="air"> text here </div>
</section>
<section id="blah2">
<div class="air"> text here </div>
</section>
ThinkingStiff
  • 62,391
  • 29
  • 139
  • 237
Adam Ware
  • 1,182
  • 10
  • 17

1 Answers1

2

Worked out my own answer:

$('#iframe').contents().find('.air').each(function(){

    var foo = $(this).html();
    //do your Stuff here

});
Adam Ware
  • 1,182
  • 10
  • 17