繁体   English   中英

删除包含外部html页面的javascript变量内的html标签

[英]Remove html tag inside a javascript variable that contains an external html page

我一直试图从我在项目的jquery对话框中显示的外部html表单中删除div。

这两个网页都属于我公司,其想法是通过对话框在主网站内显示我们的问题跟踪工具(在不同公司域中)的形式,因此只需填写即可立即添加无需从外部访问该工具的问题。

到目前为止,此方法有效(在对话框中显示外部表单):

function ShowPopup(message) {
        $(function () {
            var pweb = '<object data="http://[internal domain]" width="1024px" height="768px" />';
            $("#dialog").html(pweb);
            $("#dialog").dialog({
                title: "jQuery Dialog Popup",
                minHeight: 768,
                minWidth:1024,
                buttons: {
                    Close: function () {
                        $(this).dialog('close');
                    }
                },
                modal: true
            });
        });
    };

现在,我需要在显示该表单之前删除该表单中名为“ report_issue_header”的div。 我试过了:

$("#dialog").html(pweb);
var teaser = $("#dialog").clone();
teaser.find(".report_issue_header").remove()

要么

$("#dialog").html(pweb);
var teaser = $("#dialog").clone();
teaser = $.trim($(".report_issue_header", teaser).remove().end().html());

正如我在这里找到的: jquery删除变量(jquery对象)内的html元素

但这似乎不起作用。

我也尝试过这个javascript:

pweb.getElementsByTagName("report_issue_header").remove();

和许多类似的方法,但是没有办法解决。 我承认我是C程序员,对Javascript的经验很少,尽管我猜测它与我如何管理变量中的外部代码有关。 在我看到的其他示例中,它们仅使用$(this)。 并使用jQuery,它可以正常工作...

我注意到的第一件事是克隆了元素,因此要删除的实际上是克隆的元素,为什么不尝试

$("#dialog").html(pweb).find(".report_issue_header").remove();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM