success: function (data) {
var obj = data;
console.log(obj);
var html = "";
//清空table中的html
$("#tbody").html("");
for (var i = 0; i < data.data.length; i++) {
html = "<tr>" +
"<th><input name='checkbox' type='checkbox' value=''/></th>" +
"<td>" + data.data[i].id + "</td>" +
"<td>" + data.data[i].depart + "</td>" +
"<td>" + data.data[i].name + "</td>" +
"<td>" + data.data[i].sex + "</td>" +
"<td>" + data.data[i].work + "</td>" +
"<td>" + data.data[i].year + "</td>" +
"<td>" + data.data[i].place + "</td>" +
"<td>" + data.data[i].worktime + "</td>" +
"<td>" + data.data[i].entrytime + "</td>" +
"<td><a href='#' class='tablelink' οnclick='stopUser()'>禁用</a> | <a href='#' class='tablelink' οnclick='startUser();'>点击启用</a></td>"+
"<td><a href='#' class='tablelink' οnclick='defaultaa(this)'>修改</a> | <a href='#' class='tablelink' οnclick='deleteUserById(this);'>删除</a></td>"
"</tr>";
$("#tbody").append(html);
}
隐藏inpu框
//隐藏不留痕迹
<input type="hidden" />
<input type="text" style="display:none" />
//占位隐藏,会留下空白
<input type="text" style="visibility: hidden;" />
js点击获取当前行
<td>
<button type="button" onclick="myclick(this)" class="btn btn-warning btn-sm">点击</button>
</td>`
function myclick(obj){
var tr1 = obj.parentNode.parentNode; //获取当前对象的父节点的父节点(也就是tr)
//alert(tr1.rowIndex);
//alert(tr1.cells[0].innerText);
//alert(tr1.cells[3].innerHTML);
tr1.cells[3].innerHTML=“赋值”; //对第4个的td赋值(下标从0开始)
$(this).parents(“tr”).find(“input[name=examineId]”).val(); // 获取table隐藏input值
}