我想獲取鏈接點擊的html值。 這些鏈接使用Ajax動態創建的,所以我不認爲.bind將 的工作,我沒有最新版本的.live動態添加偵聽器到jQuery創建的內容
$('div#message').click(function() {
var valueSelected = $(this).html(); // picks up the whole id. I juust want single href!
alert(valueSelected);
return false;
});
<div id="message">
<br/>
<a class="doYouMean" href="#">location A</a>
<br/>
<a class="doYouMean" href="#">location B</a>
<br/>
<a class="doYouMean" href="#">location C</a>
<br/>
<a class="doYouMean" href="#">location D</a>
<br/>
<a class="doYouMean" href="#">location E</a>
<br/>
</div>
#2的伎倆! – davidP 2010-03-31 13:44:27