jq 点编辑出现input框可进行编辑,出现保存和取消
来源:互联网 发布:真牛皮包淘宝网 编辑:程序博客网 时间:2024/06/05 13:42
首先是效果图
下面是html前台的布局代码
再是jq的代码
<script> //页面加载时将input框和保存和取消隐藏 $(document).ready(function(){ $("input[name='xs1']").hide(); $("input[name='xs2']").hide(); $("span[class='edit']").hide(); }); //点击编辑显示input框,隐藏编辑,显示保存和取消 $(function(){ $("a[rel='edit']").click(function () { $(this).parent().parent().parent().find("input[name='xs1']").show(); $(this).parent().parent().parent().find("input[name='xs2']").show(); $(this).parent().parent().parent().find("span[class='xst1']").hide(); $(this).parent().parent().parent().find("span[class='xst2']").hide(); $(this).hide(); $(this).parent().parent().find("span[class='edit']").show(); }) }); //点击保存后获取input框的值,用ajax发送到后台进行数据库更改操作 $(function () { $("a[rel='update']").click(function () { var xs1 = $(this).parent().parent().parent().find("input[name='xs1']").val(); var xs2 = $(this).parent().parent().parent().find("input[name='xs2']").val(); var id = $(this).parent().parent().parent().find("input[name='id']").val();// var $this = $(this); $.ajax({ type: "post", url: "{:U('Mediasetdwjxswh/update')}", data: { id: id, xs1: xs1,xs2:xs2}, }).done(function (data) { if (data == "1") { alert("保存成功!"); window.location.reload(); } else alert("保存失败!"); }); }) }); //点击取消将input框隐藏和保存和取消隐藏,将编辑显示出来 $(function () { $("a[rel='cancel']").click(function () { $(this).parent().parent().parent().find("input[name='xs1']").hide(); $(this).parent().parent().parent().find("input[name='xs2']").hide(); $(this).parent().parent().parent().find("span[class='xst1']").show(); $(this).parent().parent().parent().find("span[class='xst2']").show(); $(this).parent().parent().find("span[class='edit']").hide(); $(this).parent().parent().find("a[rel='edit']").show(); }) }); </script>
每个方法是起什么作用都已经添加上了注释哦!
1 0
- jq 点编辑出现input框可进行编辑,出现保存和取消
- esay UI datagrid 行点击 编辑 出现 保存跟取消
- C# 双击ListView出现编辑框可编辑,回车确认
- 编辑-保存-取消
- 使用word编辑文字时,按空格键会出现一连串的点.怎么取消呢
- 可编辑保存ALV
- 可编辑保存ALV
- 表格点击变成input框可编辑
- IE出现无法编辑
- INPUT可编辑, tab 键可切换.
- 双击文字出现编辑文本框的JS代码,并可编辑成功
- LIST控件双击出现编辑框
- 使用putty进行vim编辑的时候,小键盘出现错误
- 页面表格可编辑input框变大的问题
- 页面表格可编辑input框变大的问题
- 令编辑窗口只能保存,不能取消
- js 可编辑并用ajax保存的a标签仿input功能代码,测试ff/ie
- 点击编辑框,出现软键盘出现问题
- iOS库.a与.framework
- ES2015(es6)和Underscore的一些用法比较
- Vue.js快速创建项目并启动
- JS截取字符串常用方法详细整理
- 每日学习20170221-分布式事务
- jq 点编辑出现input框可进行编辑,出现保存和取消
- 深入分析 Java Web 中的中文编码问题
- 3分钟了解深度学习跟量化交易是什么关系
- OJ单词翻转
- JAVA WEB从入门到精通day10 Servlet详解
- angularjs上传多张图片并预览
- Odoo Windows系统下部署方法
- sql sever增删查改之--------------查询
- mysql学习笔记(2)