【问题标题】:How to append a link's HREF with jquery?如何使用 jquery 附加链接的 HREF?
【发布时间】:2011-05-16 23:56:09
【问题描述】:

我想更改所有包含“foobar.com/?”的链接用 jquery 为 "&t=test" ("foobar.com/?&t=test") 做广告。

这是我拥有的似乎不起作用的代码。 ->

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

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

【问题讨论】:

    标签: jquery append href


    【解决方案1】:

    这是怎么做的

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

    【讨论】:

      猜你喜欢
      • 2021-11-17
      • 1970-01-01
      • 2012-03-14
      • 2012-05-17
      • 2012-01-23
      • 1970-01-01
      • 1970-01-01
      • 2011-07-27
      • 1970-01-01
      相关资源
      最近更新 更多