博客
关于我
表格 文章 - 即点即改
阅读量: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/

你可能感兴趣的文章
postfix在邮件服务器中的使用
查看>>
PostGIS 3.1.2软件安装详细教程(地图工具篇.8)
查看>>
PostGIS中获取所有EPSG的编码以及对应Proj4字符串
查看>>
SpringBoot中集成海康威视SDK实现布防报警数据上传/交通违章图片上传并在linux上部署(附示例代码资源)
查看>>
PostGIS在Windows上的下载与安装
查看>>
Qt开发——网络编程之UDP客户端
查看>>
postgis数据库优化_postgresql 性能优化
查看>>
postgis求面积、交集等相关函数
查看>>
postgis相关函数
查看>>
Postgres Docker版本安装mysql_fdw 插件
查看>>
Postgres invalid command \N数据恢复处理
查看>>
Postgres like 模糊查询匹配集合
查看>>
Postgres 自定义函数内实现 in 操作符的递归查询
查看>>
Postgres 返回当前时间前后指定天数的集合
查看>>
postgres--vacuum
查看>>
postgres--wal
查看>>
postgres--流复制
查看>>
postgres10配置huge_pages
查看>>
PostgreSQL 10.0 preview sharding增强 - pushdown 增强
查看>>
PostgreSQL 10.0 preview 变化 - pg_xlog,pg_clog,pg_log目录更名为pg_wal,pg_xact,log
查看>>