gpt4 book ai didi

javascript - 在url末尾添加字符串

转载 作者:行者123 更新时间:2023-12-03 11:11:27 25 4
gpt4 key购买 nike

我在网站上有各种链接,并且想在每个 url 的末尾添加一个特定的字符串,该字符串在 url 内有一个域 example.com。例如:所有域名为 example.com 的 url 末尾都会有一个字符串“mystring”,因此完整的 url 将为:example.com?mystring。我正在尝试完成此任务,以便我可以在网址末尾生成 key 生成器字符串。

示例 html 结构:JsFiddle

这可能吗?谢谢

最佳答案

你可以尝试像下面这样

$(function(){
//iterate all a tag having href="example.com"
$('ul li a[href="example.com"]').each(function(){
//set href with new value
$(this).attr('href',$(this).attr('href')+'?myString');
});
});

<强> DEMO

关于javascript - 在url末尾添加字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27563937/

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