使用 jquery 计算 iframe 内的标签数

发布于 2024-09-09 16:17:23 字数 261 浏览 1 评论 0原文

iframe src 是这样的:- 并且内容是动态的。如何找出a中的

  • 标签的数量内嵌框架 在服务器端或客户端使用javascript? -谢谢

  • iframe src is like this:-<iframe src="http://mysite.com/testing.php?id=7632762"></iframe>
    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

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(2

    溺渁∝ 2024-09-16 16:17:23

    假设 iframe src 与源页面位于同一域并且已完成加载其资源,那么您可以使用以下命令:

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

    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
    
    花间憩 2024-09-16 16:17:23
    $("iframe>div").each(function(){counter++;})
    

    对于其他元素也是如此。如果你在 iframe 中添加一些 id 会更容易。

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

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

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文