[英]jQuery how to load a div from a other page using load
I have a little project where I need to show items on one page from a other so I have a little categorie where you can click on. 我有一个小项目,需要在一个页面上显示另一个页面上的项目,所以我有一个小类别,您可以在其中单击。 Then I pick the attr("href");
然后,我选择attr("href");
and set that to the page I would like to load. 并将其设置为我要加载的页面。 this works. 这可行。
But how to add a <div>
to it so I online load like the <div class="holder"></div>
And not the whole div? 但是如何添加一个<div>
以便像<div class="holder"></div>
这样的在线加载而不是整个div?
This is my function: 这是我的功能:
function setupCasesFilter()
{
j(".casemenu a").click(function(e) {
e.preventDefault();
j("ul.casesholder").load(j(this).attr("href"));
});
}
Where I can add the class inside attr("href"));
我可以在attr("href"));
添加类的地方attr("href"));
? ?
If you want to load a specific div element from the url then use it this way: 如果要从URL加载特定的div元素,请按以下方式使用它:
j("ul.casesholder").load(j(this).attr("href") + " .holder");
What seems to me that you have a .holder
div on the href
page you are loading, so you can pass that div's class name which you want to load with a space for ex. 在我看来,您正在加载的href
页面上有一个.holder
div,因此您可以传递要加载的div的类名,并在其前面加上一个空格。 page.html .holder
. page.html .holder
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.