Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
iframe src 是这样的:-内容是动态的。如何通过在服务器端或客户端使用 javascript<iframe src="http://mysite.com/testing.php?id=7632762"></iframe> 找出 iframe 中的<div>或<li>或标签的数量?<p>-谢谢
<iframe src="http://mysite.com/testing.php?id=7632762"></iframe>
<div>
<li>
<p>
假设 iframe src 与源页面位于同一域并已完成加载其资源,那么您可以使用以下内容:
$("iframe").contents().find("div").length
$("iframe>div").each(function(){counter++;})
对于其他元素也是如此。如果向 iframe 添加一些 id 会更容易。