views:

25

answers:

2

iframe src is like this:-<iframe src="http://mysite.com/testing.php?id=7632762"&gt;&lt;/iframe&gt; and the content is dynamic.How to find out number of <div> or <li> or <p> tags inside a iframe by using javascript on server side or client side ? -Thank you

A: 
$("iframe>div").each(function(){counter++;})

Similarly for other elements. It would be easier if you add some id to the iframe.

Satyajit
Or just $("iframe>div").length
Christoffer
@Christoffer: that's easier, I admit.
Satyajit
That will not work. You need to use .contents
redsquare
+2  A: 

On the assumption that the iframe src is on the same domain as the source page and has finished loading its resource then you can use the following:

$("iframe").contents().find("div").length
redsquare