html代码
<td><span id="list_order">{$vo.list_order}</span> </td>
<td id="id">{$vo.id}</td>
// js代码
$(document).on('click','#list_order', function () {
//获取当前对象
var list_order = $(this).text();
//获取修改的id
var id = $(this).parent().next().html();
$(this).parent().html("<input type='text' class='fo' value='" + list_order + "'/>");
$(".fo").focus();
$(".fo").blur(function() {
//获取到修改后的值
var val = $(".fo").val();
//传到后台进行修改
$.ajax({
type: "post",
url: "ajax后台路径",
data: {id:id,list_order:val},
success: function(msg){
if(msg == 'ok'){
layer.msg('修改成功!');
window.location.reload();
}else{
layer.msg('修改失败!');
}
}
});
/*
将所有修改信息传到后端
*/
$(this).parent().html("<span id='id' style='cursor:pointer;'>" + val + "</span>");
})
})
本博客链接:https://www.cnblogs.com/dalaowang/p/11551366.html