利用jQuery如何获取当前被点击的按钮

如下代码

<tr>
    <td><a href="javascript:void(0)">点我1</a></td>
    <td><a href="javascript:void(0)">点我2</a></td>
</tr>

如果想获取被点击的a标签

可以这样写

$("a").click(function(){
    $(this).alert($(this).text());
});

即可获取相应点击的a标签的文本内容

猜你喜欢

转载自www.cnblogs.com/xQlover/p/9789861.html
今日推荐