我試圖找到類名「鏈接」跨度的文本,但我有問題。使用ID作爲變量
<div id="item-0" class="box">
.......
</div>
<div id="item-1" class="box">
<p><strong>Link: </strong><span class="link">http://www.domain.com/list44/</span></p>
<p><input type="submit" value="submit" class="load-button2"></p>
</div>
<div id="item-2" class="box">
.......
</div>
$(".load-button2").click(function(){
var id = $(this).closest('.box').attr('id');
alert(id); // showing the right box ID
var linkp = $(/*** what should i put here? ***/ "#" + id + " .link").text;
});
*什麼*的問題到底是什麼? –
'var linkp = $(「#」+ id +「.link」)。text();' –