1

我需要替换这个网址

http:///prod/ap4s/appleproducts/iphone/4S

http:///prods.aspx?prod_id=ap4s

从现有 url 中获取 productId "ap4s" 并将其作为查询字符串传递。

('a').each(function(){
   $(this).attr('href')    <--- Modify href here.. 
}

我认为替换在这里没有太大帮助。所以寻找一些更好的选择或一些建议以朝着正确的方向前进......

4

1 回答 1

1
$('a').each(function(){
   $(this).attr('href','http:///prods.aspx?prod_id='+$(this).attr('href').split('/')[3]) 
}
于 2012-04-05T19:05:59.880 回答