How to change the href for a hyperlink using jQuery

前端 未结 12 2370
孤街浪徒
孤街浪徒 2020-11-21 11:15

How can you change the href for a hyperlink using jQuery?

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 12:06

     $("a[href^='http://stackoverflow.com']")
       .each(function()
       { 
          this.href = this.href.replace(/^http:\/\/beta\.stackoverflow\.com/, 
             "http://stackoverflow.com");
       });
    

提交回复
热议问题