<script type="text/javascript">
$(function(){
$("tbody>tr>td").dblclick(function(){
var inval=$(this).html();//获取内容
var keyword=$(this).attr("key");//获取要更新的字段
var upid=$(this).parents().attr("index");//获取更新哪一行
$(this).html("<input id=’edit"+keyword+upid+"’ value=’"+inval+"’/>");//内容换成input框并保留原来内容
$("#edit"+keyword+upid).focus().live("blur",function(){//获取input标签添加动作
var upval=$(this).val();//获取新输入的内容
$(this).parents("td").html(upval);//把新输入的内容显示在td表格内
$.post("post.php",{i:upid,k:keyword,v:upval});//异步传送数据
});//live方法类似bind
});
});
</script>
具体代码打包双击编辑内容异步更新
附:参考PHP100视频制作
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有