从外部加载分区的内容与jQuery.load到自己的div [英] loading div content from external with jQuery.load into own div
本文介绍了从外部加载分区的内容与jQuery.load到自己的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说,我有两个HTML页面的设计相同,但具有不同的内容。我也有同样的 DIV 以相同的 ID 两页上。我如何使用 jQuery.load (我使用或什么的)使 DIV#conent 不会被添加到 DIV#内容的第一页的
我已经试过这样:
$(文件)。就绪(函数(){
$(A#linkHome)点击(函数(){$(#DIV内容)的负载('的index.htm#内容);});
$(A#linkPage2)点击(函数(){$(#DIV内容)的负载('page2.htm#内容);});
});
...但它最终将另一个分区到已经存在的div!
< DIV ID =内容>
< DIV ID =内容>
等等等等等等
< DIV ID =内容>
< / DIV>
解决方案
尝试使用:
$(文件)。就绪(函数(){
$(A#linkHome)点击(函数(){$(#DIV内容)的负载('的index.htm#内容*');});
$(A#linkPage2)点击(函数(){$(#DIV内容)的负载('page2.htm#内容*');});
});
在此,你得到的DIV#内容中的所有元素,但不是DIV本身。
Let's say that I have two html pages that are identically designed, but have different content. I have the same div with the same id on both pages. How do I use jQuery.load (or what do I use) so that the div#conent does not get added into the div#content of the first page.
I've tried this:
$(document).ready(function(){
$("a#linkHome").click(function(){$("div#content").load('index.htm #content');});
$("a#linkPage2").click(function(){$("div#content").load('page2.htm #content');});
});
... but it ends up adding another div to the already existing div!
<div id="content">
<div id="content">
Blah Blah Blah
<div id="content">
</div>
解决方案
Try with:
$(document).ready(function(){
$("a#linkHome").click(function(){$("div#content").load('index.htm #content *');});
$("a#linkPage2").click(function(){$("div#content").load('page2.htm #content *');});
});
in this way you get all elements inside the div#content but not the div itself.
这篇关于从外部加载分区的内容与jQuery.load到自己的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文