无法使用 jquery 从第三方脚本中删除 div



尝试从加载页面上的所有内容后加载几个 iframe 的第三方脚本中删除一个元素,由于某种原因,我的代码不起作用。

    jQuery(window).ready(function() {
    jQuery('.sharefooter-modern')
        .css("display", "none");
        console.log("removed2");
    });

我已经尝试了窗口加载,文档就绪和其他一些事情,但是在实际加载所有内容之前仍然会触发代码。

我正在尝试删除的 Html:

<div class="sharefooter-modern">

它以新的 html 正文加载在 iframe 中

带有 iframe 的完整 html https://codepen.io/anon/pen/LzMbmN 我正在尝试删除带有"病毒循环"的部分

嗨,试试这个,评论是

这样,如果你有多个div类.sharefooter-modern,并且你想不显示只有第三个,另一个是关闭全部或其中一个。问候。

jQuery(window).ready(function() {
    //jQuery("#component").contents().find('.sharefooter-modern:nth-child(3)').css("display", "none");
    jQuery("#component").contents().find(".sharefooter-modern").css("display", "none");
    console.log("removed2");
});

显然,由于跨源策略,我无法隐藏元素,但我使用另一种方法解决了我的特定问题 - 我将 iframe 放置在固定高度的div 中以剪切底部并设置溢出:隐藏。希望它能帮助某人。

最新更新