<a>实现按钮的javascript+jquery编程实例

涉及知识点:怎样实现让注册的function获取当前<a>,以便通过它进行其他操作

风格一:
 1.html端:

<td class="text-center"><a class="delete" data-index="' + trIndex + '" href="javascript:void(0)"><i class="fa fa-minus" aria-hidden="true"></i></a></td>    

2.javascript端:

$("body").delegate(".delete", "click", function () {
    var $this = $(this);
    if ($this.parents('tr').next().length == 0)
        return;
    $this.parents('tr').remove();
});

风格二:
1.html端

<td><a class='delete' title='删除' onclick='DeleteNewRow(this);' href='javascript:void(0)'><i class='fa fa-minus' aria-hidden='true'></i></a></td>

2.javascript端

function DeleteNewRow(obj) {
    $(obj).parent().parent().remove();
}

 

posted @ 2017-09-21 16:11  轴轴  阅读(465)  评论(0编辑  收藏  举报