双击文本框,可编辑状态,当鼠标移走后
2015-05-07 12:37
197 查看
// JavaScript Document
$(function() { //获取class为caname的元素 $(".caname").click(function() { var td = $(this); var txt = td.text(); var input = $("<input type='text'value='" + txt + "' style='width:23px;'/>"); td.html(input); input.click(function() { return false; }); //获取焦点 input.trigger("focus"); //文本框失去焦点后提交内容,重新变为文本 input.blur(function() { var newtxt = $(this).val(); //判断文本有没有修改 if (newtxt != txt) { td.html(newtxt); var wid = $.trim(td.prev().text()); var database=$("#database").val(); $.ajax({ type:"POST", url:"/admin.php/Index/modifypx", data:{id:wid,paixu:newtxt,database:database}, dataType:"json", success:function(data){ if(data ==1){ $.gritter.add({ // (string | mandatory) the heading of the notification title: '修改排序成功', // (string | mandatory) the text inside the notification text: ' ', time: 1000 }); window.location.reload(); }else{ $.gritter.add({ // (string | mandatory) the heading of the notification title: '修改排序失败', // (string | mandatory) the text inside the notification text: ' ', time: 1000 }); } } }); } else { td.html(newtxt); } }); });});
来自为知笔记(Wiz)
$(function() { //获取class为caname的元素 $(".caname").click(function() { var td = $(this); var txt = td.text(); var input = $("<input type='text'value='" + txt + "' style='width:23px;'/>"); td.html(input); input.click(function() { return false; }); //获取焦点 input.trigger("focus"); //文本框失去焦点后提交内容,重新变为文本 input.blur(function() { var newtxt = $(this).val(); //判断文本有没有修改 if (newtxt != txt) { td.html(newtxt); var wid = $.trim(td.prev().text()); var database=$("#database").val(); $.ajax({ type:"POST", url:"/admin.php/Index/modifypx", data:{id:wid,paixu:newtxt,database:database}, dataType:"json", success:function(data){ if(data ==1){ $.gritter.add({ // (string | mandatory) the heading of the notification title: '修改排序成功', // (string | mandatory) the text inside the notification text: ' ', time: 1000 }); window.location.reload(); }else{ $.gritter.add({ // (string | mandatory) the heading of the notification title: '修改排序失败', // (string | mandatory) the text inside the notification text: ' ', time: 1000 }); } } }); } else { td.html(newtxt); } }); });});
来自为知笔记(Wiz)
相关文章推荐
- swing jtable 单元编辑事件(包括通过键盘获取焦点后编辑和鼠标双击后进入编辑状态)
- 实现鼠标双击DataGrid的一行,使该行成为编辑状态
- gridview编辑状态时文本框自动计算(js方法)
- 处理文本框的鼠标事件,判断鼠标的状态
- JTable只要一双击就进入编辑状态,禁止的方法实现
- jQuery实现鼠标双击Table单元格变成文本框及输入内容后更新到数据库的方法
- 双击单元格变成可编辑的文本框
- html中a标签href属性的一个坑(二)-a标签双击可编辑状态下问题
- esayui 编辑单元格 双击编辑一个单元格,不是一行,单击其他后,关闭编辑状态,单击双击编辑可以任意调整
- 文本框编辑状态下隐藏键盘的方式
- JS实现双击编辑可修改状态的方法
- 双击文字出现编辑文本框的JS代码,并可编辑成功
- jQuery实现鼠标双击Table单元格变成文本框及输入内容后更新到数据库的方法
- 鼠标右键Table的td弹出多级菜单,双击td编辑
- 文本框的编辑状态的修改方法:启用编辑/禁用编辑
- 切换为文本框编辑状态,点击空白区域保存修改
- JS实现双击编辑可修改状态的方法
- javascript 双击文本框编辑功能代码
- 单击、双击div进入编辑状态