如何使用jquery附加链接的HREF?

Dav*_*ave 3 jquery append href

我想更改包含"foobar.com/?"的所有链接 使用jquery来广告"&t = test"("foobar.com/?&t=test").

这是我的代码似乎不起作用. - >

$('a[href*="foobar.com/?"]').attr(href).append('&t=test');
Run Code Online (Sandbox Code Playgroud)

我的代码出了什么问题?或者更改所有链接的更合适的方法是什么?

Gab*_*oli 7

这是怎么做的

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