show only one div within an iframe (javascript, JQuery…)

后端 未结 3 884
梦谈多话
梦谈多话 2021-01-11 16:13

First just let me say I\'m open to ideas on a different approach altogether.

I have and iframe as such:

3条回答
  •  难免孤独
    2021-01-11 16:24

    $("iframe").contents().find("*:not(#loginInnerBox)").remove();
    

    Be aware this would only work on iframes loaded from the same domain (same origin policy)

    EDIT: Probably this removes children of loginInnerBox as well. In that case you could try to clone it before:

    var iframe   = $("iframe").contents(),
        loginBox = iframe.find("#loginInnerBox").clone();
    
    iframe.find("*").remove();
    iframe.append(loginBox);
    

    Something like that..

提交回复
热议问题