当前位置: 编程技术>jquery
jquery操作tr与td内容的方法举例
来源: 互联网 发布时间:2014-09-03
本文导语: jquery操作tr与td内容的方法举例,比较简单,供初学的朋友参考。 代码示例: $(document).ready(function () { $("#selEmployee").click(function () { var $table = $("#tbProEmployee tr"); var len = $table.length; var trid = "tbProEmployee" + len; var...
jquery操作tr与td内容的方法举例,比较简单,供初学的朋友参考。
代码示例:
$(document).ready(function () {
$("#selEmployee").click(function () {
var $table = $("#tbProEmployee tr");
var len = $table.length;
var trid = "tbProEmployee" + len;
var strDeviceTr = "";
strDeviceTr += "";
strDeviceTr += "" + "姓名" + "";
strDeviceTr += "";
strDeviceTr += "保存 | 删除";
strDeviceTr += " ";
$("#tbProEmployee").append(strDeviceTr);
});
});
function SaveProEmployee(index) {
//ajax保存
var tr = $("tr[id=" + index + "]");
var employee = tr.find("#txtEmployeeName").text();
var remark = tr.find("#txtRemark").val();
var strtd = "";
strtd += "" + employee + "";
strtd += "" + remark + "";
strtd += "修改 | 删除";
tr.html(strtd);
}
function UpdateProEmployee(index) {
//ajax保存
var tr = $("tr[id=" + index + "]");
var employee = tr.find("#txtEmployeeName").text();
var remark = tr.find("#txtRemark").text();
var strtd = "";
strtd += "" + employee + "";
strtd += "";
strtd += "保存 | 删除";
tr.html(strtd);
}
function DelProEmployee(index) {
if (confirm("Are you sure?")) {
$("tr[id=" + index + "]").remove();
}
}