0

我正在使用 jquery ajax 加载带有另一个页面内容/html 的页面部分。\

$(function() {
   app.xhr = $.ajax({
                                    url: url, 
                                    dataType: "html", 
                                    cache: false,
                                    success : function(html)
                                        {
                                            app.html = $(html);
                                            setTimeout(function(){
                                                app.insertPageData();
                                                app.xhr = null;
                                            },100)

                                        },
                                    error : function()
                                        {
                                            alert("Not Found")
                                        }
                                })


insertPageData : function()
                        {

                           $('div.data').html(app.html.find(".content").html())

                        }
});

所以这是IE特有的问题。app.html 包含页面的 HTML,我需要从不与 IE 一起使用的页面中提取一个特定的 div html。

有没有其他方法可以从 HTML 中提取 HTML?

谢谢/古西姆龙

4

1 回答 1

1

你在你想要的 div 上有一个 id 或 class 吗?另外,通过提取,您的意思是这就是您想要的,还是您想从 HTML 中删除它?

如果你想删除div,并假设你有一个 id,你可以这样做:

app.html.remove('#id-of-div');

如果你想要的只是 div 而不是别的,那么你会这样做:

app.html = app.html.find('#id-of-div');
于 2012-05-11T13:15:46.113 回答