gif效果
代码段
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src = "jquery1.js" ></script>
<style>
table , table td{
border: 1px solid #ccc;
border-collapse: collapse;
}
td{
width: 150px;
height: 30px;
}
input{
width: 148px;
border: 0px;
height: 26px;
display: none;
}
div{
height: 30px;
width: 100%;
line-height: 30px;
}
</style>
</head>
<body>
<table>
<tr><td><div>001</div><input type="text" value ="001"/></td><td>张三</td></tr>
<tr><td><div>001</div><input type="text" value ="001"/></td><td>张三</td></tr>
<tr><td><div>001</div><input type="text" value ="001"/></td><td>张三</td></tr>
<tr><td><div>001</div><input type="text" value ="001"/></td><td>张三</td></tr>
<tr><td><div>001</div><input type="text" value ="001"/></td><td>张三</td></tr>
<tr><td><div>001</div><input type="text" value ="001"/></td><td>张三</td></tr>
</table>
<script>
$(function(){
$("div").on("click",function(){
$(this).next(":input").show().focus();
$(this).hide();
$(":input").val($(this).text());
})
$(":input").blur(function () {
$(this).hide();
$(this).prev("div").show();
$(this).prev("div").text($(this).val());
})
});
</script>
</body>