从ajax加载的页面加载特定的元素 [英] load a specific element from an ajax loaded page

查看:60
本文介绍了从ajax加载的页面加载特定的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那么...嗯,如何从ajax加载的页面加载特定的DIV?

So...um, how can I load a specific DIV from a page loaded via ajax?

我有这个工作

$.get(url,function(content){
    //ajax content here

});

正在加载的页面中有一个名为#content的div.我想将该div加载到主页上名为#wrap的div中.

there is a div called #content from the page being loaded. I want to load that div into my div called #wrap on the main page.

我在想这样的事情

$("#wrap").load($(content).find("#content"));

推荐答案

这就是我要做的事情:

$.post('THE LINK',
    function(data)
    {
        $('#wrap').html($(data).select('#content').html());
    }
);

小提琴: http://jsfiddle.net/mazzzzz/P77Ev/

这篇关于从ajax加载的页面加载特定的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆