jquery:获得当前点击对象 : $(this)
2021-06-05 10:03
标签:state lse remove val cti round path class image jquery:获得当前点击对象 : $(this) 标签:state lse remove val cti round path class image 原文地址:https://www.cnblogs.com/huiy/p/12334297.html$(".state").click(function() {
var val=$(this).attr("id");
alert(val);
});
$("#tbody td").click(function() {
//这时能够获得正确的被点击对象
var tdID = $(this).attr(‘id‘);
$.post(appPath + "/app/teach/train/save/", {
publishID : $(‘#publishID‘).val(),
teachDate : $(‘#teachDate‘).val(),
stage : $(‘#stage‘).val()
}, function(result) {
if (result.state == ‘succ‘) {
//在此处不能用$(this)获得被点击的对象,得到的是ajax对象
$(‘#‘ + tdID).removeClass();
$(‘#‘ + tdID).addClass(state);
} else {
top.errorLayer(‘维护排班‘, ‘保存失败‘);
}
}, ‘json‘);
});
下一篇:在IIS上发布netcore项目