jq遍历table怎么进行点击td进行编辑
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>分页</title>
<script type="text/javascript"
src="${pageContext.request.contextPath}/jquery-easyui/jquery.min.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
$(function() {
$("#cha")
.click(
function() {
$
.ajax({
url : 'msg/selHis',
type : 'POST',
dataType : 'json',
data : {
StartDate : $("#qi").val(),
EndDate : $("#zi").val()
},
success : function(msg) {
var tb = document
.getElementById("set");
for (var n = tb.rows.length - 1; n > 0; n--) {
tb.deleteRow(n);
}
for (i = 0; i < msg.length; i++) {
$("#set")
.append(
"<tr><td><input class = 'check' type='checkbox'></td><td>"
+ (msg[i].yybh == undefined ? " "
: msg[i].yybh)
+ "</td><td>"
+ (msg[i].jyckh == undefined ? " "
: msg[i].jyckh)
+ "</td><td>"
+ (msg[i].posjysj == undefined ? " "
: msg[i].posjysj)
+ "</td><td>"
+ (msg[i].sfzhm == undefined ? " "
: msg[i].sfzhm)
+ "</td><td>"
+ (msg[i].jylx == undefined ? " "
: msg[i].jylx)
+ "</td><td>"
+ (msg[i].posjyje == undefined ? " "
: msg[i].posjyje)
+ "</td><td>"
+ (msg[i].shh == undefined ? " "
: msg[i].shh)
+ "</td><td>"
+ (msg[i].zdbh == undefined ? " "
: msg[i].zdbh)
+ "</td><td>"
+ (msg[i].bhcfybz == undefined ? " "
: msg[i].bhcfybz)
+ "</td><td>"
+ (msg[i].bz1 == undefined ? " "
: msg[i].bz1)
+ "</td><td>"
+ (msg[i].bz2 == undefined ? " "
: msg[i].bz2)
+ "</td><td>"
+ (msg[i].bz3 == undefined ? " "
: msg[i].bz3)
+ "</td></tr>")
}
}
});
});
$('table tr td').click(
function() {
if (!$(this).is('.input')) {
$(this).addClass('input').html(
'<input type="text" value="' + $(this).text()
+ '" />').find('input').focus().blur(
function() {
var thisid = $(this).parent().siblings(
"th:eq(0)").text();
var thisvalue = $(this).val();
var thisclass = $(this).parent().attr(
"class");
$.ajax({
type : 'POST',
url : 'update.php',
data : "thisid=" + thisid
+ "&thisclass=" + thisclass
+ "&thisvalue=" + thisvalue
});
$(this).parent().removeClass('input').html(
$(this).val() || 0);
});
}
}).hover(function() {
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
});
</script>
</head>
<body>
<div>
起:<input id="qi" class="easyui-datebox" /> 止:<input id="zi"
class="easyui-datebox" /> <input id="cha" type="button" value="查询" />
<input id="upload" type="button" value="上传选中交易">
<table id="set" border="1" cellpadding="0" cellspacing="0"
bordercolor="E7F0FF">
<tr bgcolor="E7F0FF">
<th>选择</th>
<th>医药机构编号</th>
<th>POS签购单交易参考号</th>
<th>POS交易时间</th>
<th>身份证号码</th>
<th>交易类型</th>
<th>POS交易金额</th>
<th>商户号</th>
<th>终端编号</th>
<th>包含处方药标志</th>
<th>备注1</th>
<th>备注2</th>
<th>备注3</th>
</tr>
</table>
</div>
</body>
</html>