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

你可能感兴趣的文章
php curl_init函数用法(http://blog.sina.com.cn/s/blog_640738130100tsig.html)
查看>>
php curl_multi批量发送http请求
查看>>
php curl请求微信发红包接口出现错误:Peer's Certificate issuer is not recognized.
查看>>
PHP curl请求错误汇总和解决方案
查看>>
php declare(ticks=1)
查看>>
UVA 10474
查看>>
php echo 输出 锘?... 乱码问题
查看>>
PHP empty、isset、isnull的区别
查看>>
ReferenceQueue的使用
查看>>
PHP FastCGI进程管理器PHP-FPM的架构
查看>>
referenceQueue用法
查看>>
Springboot处理跨域的方式(附Demo)
查看>>
php flush()刷新不能输出缓冲的原因分析
查看>>
Referenced classpath provider does not exist: org.maven.ide.eclipse.launchconfig
查看>>
Refactoring-Imporving the Design of Exsiting Code — 代码的坏味道
查看>>
PHP imap 远程命令执行漏洞复现(CVE-2018-19518)
查看>>
php include和require
查看>>
ref 和out 区别
查看>>
php JS 导出表格特殊处理
查看>>
php json dom解析
查看>>