博客
关于我
表格 文章 - 即点即改
阅读量:581 次
发布时间:2019-03-11

本文共 1353 字,大约阅读时间需要 4 分钟。

基于jQuery的即点即改功能实现,简单而实用,功能完整且支持发送请求。以下将从HTML、CSS和JavaScript三个方面详细说明实现过程。

**

基于jQuery的即点即改,简单实用,完整的,包括发送请求!

**

**

html

**

IDcard Name Address
1 袁梦坤 河南省商丘市柘城县
2 刘凯歌 河南省商丘市柘城县

**

css

**

td {  border: 1px solid #0094ff;  text-align: center;}

**

js(注释详细,便于新手理解)

**

$(function() {  $(document).on("click", ".gai", function() {    //避免在文本输入框上点击    if ($(this).children("input").prop("type") == 'text') return false;    //获取并存储原有文本    var data = $(this).html();    //生成带有输入框的新内容    var input = '';    $(this).html(input);    //自动获得光标位置    $(this).children("input").focus();  });  $(document).on("blur", "#ai", function() {    //获取修改后的内容    var data = $(this).val();    //确定修改的ID    var id = $(this).parents("tr").prop("id");    //确定修改的字段    var param = $(this).parent().attr("param");    //输出修改信息提示    alert("修改的ID:" + id + "|" + "修改的字段:" + param + "|" + "修改后的内容:" + data);    //发送AJAX请求    $.ajax({      type: "post",      url: "",      data: {        "data": data,        "id": id,        "param": param      },      success: function(data) {        if (data == 1) {          obj.parent().html(data);        }      }    });  });});

转载地址:http://chnvz.baihongyu.com/

你可能感兴趣的文章
POJ 3041 Asteroids(二分匹配模板题)
查看>>
Qt笔记——标准文件对话框QFileDialog
查看>>
poj 3083 Children of the Candy Corn
查看>>
POJ 3083 Children of the Candy Corn 解题报告
查看>>
POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)
查看>>
Qt笔记——控件总结
查看>>
poj 3262 Protecting the Flowers 贪心
查看>>
poj 3264(简单线段树)
查看>>
Qt笔记——布局管理三件套分割窗口、停靠窗口和堆栈窗口
查看>>
poj 3277 线段树
查看>>
POJ 3349 Snowflake Snow Snowflakes
查看>>
POJ 3411 DFS
查看>>
poj 3422 Kaka's Matrix Travels (费用流 + 拆点)
查看>>
Qt笔记——官方文档全局定义(二)Functions函数
查看>>
POJ 3468 A Simple Problem with Integers
查看>>
poj 3468 A Simple Problem with Integers 降维线段树
查看>>
poj 3468 A Simple Problem with Integers(线段树 插线问线)
查看>>
poj 3485 区间选点
查看>>
poj 3518 Prime Gap
查看>>
poj 3539 Elevator——同余类bfs
查看>>