<tbody>
<tr>
<#if scopes?exists>
<#list scopes as scopes>
<td id='${(scopes.scopeId)?default(0)}'>${(scopes.lowerLimit)?default("")}</td>
<td id='${(scopes.scopeId)?default(0)}'>${(scopes.upperLimit)?default("")}</td>
</tr>
</#list>
</#if>
</tr>
</tbody>

js:

<script type="text/javascript"
src="http://www.17sucai.com/static/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function() {
$('table td').click( //定义点击事件
function() {
if (!$(this).is('.input')) {
//获取该td的id
var this_id=$(this).attr("id");
alert(this_id);
//如果当前不是.input类
$(this).addClass('input')
.html(
'<input type="text" name="inputid" id="inputid" value="' + $(this)
.text() + '" />').find('input')
.focus().blur(function() {
//失去焦点获取值,存入数据库
var inputid = document.getElementById("inputid").value; //获取该写入的值
//alert(inputid);
$.ajax({
     url:'myChangeTest.action',
data:{
sendTime: (new Date()).getTime(),
this_id: this_id,
inputid: inputid
},
type:"post",
async:false,
dataType:"json",
success:function(data){
if(data.success){
alert("sucess");
}else{ }
}
}); //当前添加类获得元素新插入一个input通过遍历获得input定义伪类,当失去焦点以后在定义一个方法
$(this).parent().removeClass('input')
.html($(this).val() || 0);
//当前查找每个元素,删除掉input类获得input所有元素的值并且和0
});
}
}).hover(function() {
//定义伪类
$(this).addClass('hover');
}, function() {
//定义方法
$(this).removeClass('hover');
}); });
</script>
<style type="text/css">
/* 一些网页的样式 */
body {
font-family: "Segoe UI", Frutiger, Tahoma, Helvetica, "Helvetica Neue",
Arial, sans-serif;
font-size: 62.5%;
} table {
border-collapse: collapse;
} td,th {
text-align: center;
border: 1px solid #ddd;
padding: 2px 5px;
} caption {
margin: 0 0 .5em;
font-weight: bold;
} table {
width: 500px;
height: 200px;
margin-left: 30px;
} td,th {
font-size: 1.2em;
padding: 2px;
width: 13%;
} th {
background-color: #f4f4f4;
} caption {
font-size: 1.5em;
} table {
float: left;
margin: 40px 40px 0 0;
} .demo {
width: 500px;
margin: 0 auto;
} /* input */
td input {
border: 1px solid orange;
background: yellow;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
position: absolute;
padding: 8px 0;
text-align: center;
width: 60px;
margin: -17px 0 0 4px;
font-size: 1.4em;
} td.input {
padding: 0;
position: relative;
} td.hover {
background: #eee;
}
</style>

心得,就是焦点的问题,失去焦点的时候 ajax 传到后台保存

jq通过对象获取其ID值,再简单ajax传到后台改值的更多相关文章

  1. jq通过对象获取其ID值

    $(this).click(function(){ var this_id=$(this).attr("id");// attr(属性名) 获取属性的值 alert(this_id ...

  2. Thinkphp 获取最大值id值

    有时候项目需要获取数据库最大的id值,比如生成订单,做排序号,那么Thinkphp 如何获取最大值id值. $info=D('Customer')->where('1=1')->order ...

  3. js判断是否是对象获取子窗体值

    判断是否是对象 Object.prototype.toString.call(obj) 装换为数组 Array.prototype.slice.call(obj) 父窗体获取值子窗体值$(functi ...

  4. 数据库插入数据返回当前主键ID值方法

    当我们插入一条数据的时候,我们很多时候都想立刻获取当前插入的主键值返回以做它用.我们通常的做法有如下几种: 1. 先 select max(id) +1 ,然后将+1后的值作为主键插入数据库: 2. ...

  5. Android(java)学习笔记105:Map集合的遍历之键值对对象找键和值

    package cn.itcast_01; import java.util.HashMap; import java.util.Map; import java.util.Set; /* * Map ...

  6. Java基础知识强化之集合框架笔记53:Map集合之Map集合的遍历 键值对对象找键和值

    1. Map集合的遍历(键值对对象找键和值) Map -- 夫妻对  思路:  A: 获取所有结婚证的集合  B: 遍历结婚证的集合,得到每一个结婚证  C: 根据结婚证获取丈夫和妻子 转换:  A: ...

  7. EF-获取自增ID值

    EF6中,如果将模型类的ID属性设置为主键自增,则我们在外部怎么对其赋值,数据库依然会将该值自增,而不会处理外部给的值. 如果我们在新增数据之后,需要用到这个自增的ID主键,怎么获取呢?EF6在执行完 ...

  8. 数据库插入数据返回当前自增主键ID值的方法

    当我们插入一条数据的时候,我们很多时候都想立刻获取当前插入的主键值返回以做它用.我们通常的做法有如下几种: 1. 先 select max(id) +1 ,然后将+1后的值作为主键插入数据库: 2. ...

  9. Android(java)学习笔记44:Map集合的遍历之键值对对象找键和值

    1. Map集合的遍历之 键值对对象找 键和值: package cn.itcast_01; import java.util.HashMap; import java.util.Map; impor ...

随机推荐

  1. [leetcode]31. Next Permutation下一个排列

    Implement next permutation, which rearranges numbers into the lexicographically next greater permuta ...

  2. [leetcode]35. Search Insert Position寻找插入位置

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  3. 机器学习(三)--------多变量线性回归(Linear Regression with Multiple Variables)

    机器学习(三)--------多变量线性回归(Linear Regression with Multiple Variables) 同样是预测房价问题  如果有多个特征值 那么这种情况下  假设h表示 ...

  4. Spring 框架XML文件的配置文件

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns:xsi="http://www ...

  5. 学习STM32,你不得不了解的五大嵌入式操作系统

    学习STM32,你不得不了解的五大嵌入式操作系统                                                  原标题:学习STM32,你不得不了解的五大嵌入式操作 ...

  6. 【Selenium】【BugList3】firefox与Selenium版本不兼容,报: Message: Unsupported Marionette protocol version 2, required 3

    环境信息:Windows7 64位 + python 3.6.5 + selenium 3.11.0 +pyCharm 1 #coding=utf-8 2 from selenium import w ...

  7. 测试快速关闭innodb的方法

    测试mysqlporformanceblog提供的减少关闭innodb时间的方法 经常发现一些MySQL镜像库的InnoDB的关闭时间会特别久,mysqlperformanceblog给出了一个不错的 ...

  8. centos7 安装搜狗输入法

    1.root权限,卸载 ibus : yum remove ibus 2.加入EPEL源   sudo yum install epel-release 3.添加mosquito-myrepo源 su ...

  9. javascript字符串方法总结

    一.单引号字符串内部可以使用双引号,双引号字符串内部也可以使用单引号 "hello 'world'" 'welcome "to" js' 二.多行和转义 如果要 ...

  10. 加盟阿里!贾扬清被曝从Facebook离职,任阿里硅谷研究院VP

    3 月 2 日傍晚,知乎上爆出一则 AI 人事变动大消息——Caffe 作者贾扬清将从 Facebook 离职. 短短数小时,就有近 10 万人浏览这个问题.不仅如此,据 AI 前线爆料,贾扬清离开 ...