gpt4 book ai didi

jquery - url 中的查询字符串为 :

转载 作者:太空宇宙 更新时间:2023-11-04 13:07:03 25 4
gpt4 key购买 nike

$("#menu a").each(function(index) {
if($.trim(this.href) == window.location.href) {
$('div', this).addClass("cc");
}
});

这是去的时候的工作

example.com/foo/foo/

例如导航到第二页时

example.com/foo/foo/p:2

这是行不通的。如何进行该查询。

最佳答案

使用 .indexOf 函数比较 URL。

$("#menu a").each(function(index) {
var currentURL = window.location.href;
var aHref = $.trim(this.href);
if(currentURL.indexOf(aHref) !== -1) {
$('div', this).addClass("cc");
}
});

关于jquery - url 中的查询字符串为 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39637214/

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