<span id="one"><a id="google" href="google.com/">link1</a></span> <br />
<span id="two"><a id="yahoo" href="yahoo.com/">link2</a></span>
<br />
<br />
<span class="click" id=1>click one</span> <br />
<span class="click" id=2>click two</span> <br />
<span class="click" id=3>click three</span> <br />
$(".click").live('click', function() {
$("a").attr('href', $("a").attr('href').replace(/\d*$/, $(this).attr('id')));
});
如果我點擊例如點擊一個然後鏈接:正則表達式+的jQuery - 修改文字
<span id="one"><a id="google" href="google.com/1">link1</a></span> <br />
<span id="two"><a id="yahoo" href="google.com/1">link2</a></span>
代替:
<span id="one"><a id="google" href="google.com/1">link1</a></span> <br />
<span id="two"><a id="yahoo" href="yahoo.com/1">link2</a></span>
活生生的例子:http://jsfiddle.net/wtAbp/14/
我該如何修復它?