【问题标题】:How can I remove elements in an iframe using JQuery?如何使用 JQuery 删除 iframe 中的元素?
【发布时间】:2015-08-05 22:06:29
【问题描述】:

我已将链接元素添加到 iframe 的 (ivuFrm_page0ivu1) 内容中,并希望在选择按钮时删除这些元素。我使用的代码在这里:

function removeAddedElements(){

console.log("called removeAddedElements()");
$("#ivuFrm_page0ivu1").contents().find(".linkUp").each(function (index, element) {
    $(this).remove
    console.log("removed one linkUp");
});
}

它会遍历我拥有的四个元素,但不会删除它们。它们保持可见。如何删除这些?

【问题讨论】:

    标签: javascript jquery html iframe


    【解决方案1】:

    .remove 不是jquery 中的有效函数。试试$(this).remove()

    function removeAddedElements(){
    
        console.log("called removeAddedElements()");
        $("#ivuFrm_page0ivu1").contents().find(".linkUp").each(function (index, element) {
            $(this).remove()
            console.log("removed one linkUp");
        });
        }
    

    Documentation here

    【讨论】:

    • 感谢一百万! 10 分钟后我会接受!
    • 很高兴它对您有所帮助。
    猜你喜欢
    • 2021-07-30
    • 2015-10-26
    • 1970-01-01
    • 1970-01-01
    • 2020-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多