gpt4 book ai didi

javascript - 将容器 #id 添加到 .load ('$(this).attr("href"));

转载 作者:行者123 更新时间:2023-11-28 14:00:45 25 4
gpt4 key购买 nike

我只想从链接指向的页面中提取特定的 div。

我的链接格式如下:<a href="about-smith.asp" class="pic">img</a>

$(function(){
$("a.pic").live('click', function (e) {
e.preventDefault();
$("#subsidebar").load($(this).attr("href") + "#subcontent");
});
});

我希望只从 about-smith.asp 中提取 #subcontent div。它显示的是 #subsidebar div 中的内容,但它是整个页面。

最佳答案

您需要在 url 和选择器之间添加空格:

$("#subsidebar").load($(this).attr("href") + " #subcontent");
^

关于javascript - 将容器 #id 添加到 .load ('$(this).attr("href"));,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5328679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com