在另一个页面上加载 div 的内容 [英] Load content of a div on another page
本文介绍了在另一个页面上加载 div 的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您将从此代码中看到它从哈希标记加载内容 URL.无论如何只能从该外部页面加载一个 div 元素.
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));
});
});
所以类似于 .substring(#inload_content(1))
但这不起作用.
谢谢
推荐答案
你只需要在url后面添加一个jquery选择器即可.
You just need to add a jquery selector after the url.
参见:http://api.jquery.com/load/
直接来自 API 的示例:
Example straight from the API:
$('#result').load('ajax/test.html #container');
所以它的作用是从指定的 url 加载 #container 元素.
So what that does is it loads the #container element from the specified url.
这篇关于在另一个页面上加载 div 的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文