开发者

How to append a link's HREF with jquery?

开发者 https://www.devze.com 2023-03-06 12:20 出处:网络
I want to change all links containing \"foobar.com/?\" to ad \"&t=test\" (\"foobar.com/?&t=test\") with jquery.

I want to change all links containing "foobar.com/?" to ad "&t=test" ("foobar.com/?&t=test") with jquery.

This is the code I have that does not seem to work. ->

$('a[href*=开发者_StackOverflow"foobar.com/?"]').attr(href).append('&t=test');

What is wrong with my code? Or what is a more proper way to change all the links?


this is how to do it

$('a[href*="foobar.com/?"]').each(function(){
  this.href += '&t=test';
});
0

精彩评论

暂无评论...
验证码 换一张
取 消