我想知道如何通过单击链接获得最后一个 child 的提醒。
<h3 id="comment:5" class="myclass">
这是我得到的结果:
$('#lastcomment').click(function() {
alert('Handler for .click() called.');
});
我的目标是通过单击链接跳转到最后一条评论。我想对于第一步来说,警报就可以了。这样我就可以看到评论的最后一个 child 。
非常感谢任何帮助。
最佳答案
$("#lastcomment").click(function () {
var lastComment = $("h3[id^=comment]:last");
alert(lastComment.attr("id"));
}
关于javascript - 选择最后一个 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3768641/