jQuery replacing relative links

后端 未结 6 1272
忘掉有多难
忘掉有多难 2020-12-19 17:33

Hopefully someone can explain some odd behavior I\'ve encountered with jQuery. The following script is looking for relative links on my page and replacing them with absolut

6条回答
  •  猫巷女王i
    2020-12-19 17:57

    Try something like this:

    if(! /http/.test( cur_href) ){
       $(this).attr("href", 'http://www.mysite.com'+cur_href);
    
    }
    

提交回复
热议问题