在另一个页面上加载div的内容 [英] Load content of a div on another page

查看:120
本文介绍了在另一个页面上加载div的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将从此代码中看到它从哈希标记中加载内容网址。

  $(function(){
if; //只有一个div元素是从外部页面加载的。 (location.hash)$(#content_inload)。load(location.hash.substring(1));
$(#nav a)。click(function(){
$( #content_inload)。load(this.hash.substring(1));
});
});

类似于 .substring(#inload_content(1))之后的内容code>



但不起作用。

谢谢

http://api.jquery.com/load/



直接来自API的示例:

  $('#result')。load('ajax / test.html #container' ); 

所以它会从指定的url加载#container元素。


You will see from this code that it loads the content URL from the hash tag. Is there anyway to load only a single div element from that external page.

$(function() {
    if(location.hash) $("#content_inload").load(location.hash.substring(1)); 
    $("#nav a").click(function() {
            $("#content_inload").load(this.hash.substring(1));
    });
});

so something like after .substring(#inload_content(1))

but that does not work.

Thanks

解决方案

You just need to add a jquery selector after the url.

See: http://api.jquery.com/load/

Example straight from the API:

$('#result').load('ajax/test.html #container');

So what that does is it loads the #container element from the specified url.

这篇关于在另一个页面上加载div的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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