ajm
ajm

Reputation: 13213

How to find and iterate all iframe elements inside a div using jquery?

I have a div with some id and the div has some iframe elements. I need to find those iframe elements and iterate over them.

Currently I can get all iframe elements using following script.

$("iframe").each(
                 function(index, elem) {
                     elem.setAttribute("width","245");
                     elem.setAttribute("height","170");
                 }
            );

How do I get iframes inside a div with some id?

Upvotes: 1

Views: 1250

Answers (1)

Blender
Blender

Reputation: 298226

Just add it to the selector:

$('#the_id iframe')

Or if you don't like long selectors:

$('#the_id').find('iframe')

Upvotes: 2

Related Questions