jquery 轻松实现 双击编辑文本框
By admin
- One minute read - 46 words<script type="text/javascript">
$(document).ready(function(){
$(".update").dblclick(function(){
id = $(this).attr('id');
text = $(this).text();
if(text){
$(this).html("<input type='text' size=12 name="+id+" value="+text+">");
$(".update > input").focus().blur(function(){
$.ajax({
type: "POST",
url: "/data/dbedit",
data: "id="+id+"&no="+$("#"+id+" >input").val(),
success: function(msg){ $("#"+id).text(msg); }
});
})
}
})
})
</script>
<table>
</tr>
<td style="text-align:center;" class="update" id="123" >文本内容</td>
</tr>
</table>