jquery常用技巧与代码总结
1.jquery动态删除表格行或单元格
$("a[todo*='del']").click(function(e){
var id = $(this).attr('todel');//获取ID
var now=$(this);//防止作用域被篡改
if (confirm("您确定要删除吗?")) {
$.get("/p/ajax/pdel.do", {
id: id
}, function(data){
switch (data._rc) {
case "success":
alert('删除成功', '删除账号');
now.parent().parent().find("td").eq(2).html("");
now.parent().parent().find("td").eq(3).html("");
now.parent().parent().find("td").eq(4).html("");
now.parent().parent().find("td").eq(4).html("<a href='../p/paddpre.do?pId=" + id + "'>添加账号</a>");
//$("#po"+id).remove();删除整行
break;
default:
jAlert("操作成功!");
break;
}
});
}
})