高手求助,用js如何实现这样的功能? 在table中每个td里都有值,如果点击td,td中出现一个input输入框, 输入框里显示原来td里的值,然后可以修改,修改后失去焦点会保存修改后的值,不修改就显示原来的值。请就用js做,不要用jquery,我不懂jquery 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 动态生成input也可以,下面这个是用的障眼法<!DOCTYPE HTML><html> <head> <meta charset="gb2312" /> <title></title> <style> * { margin:0; padding:0; font-size:14px; } table { margin:100px; } td { width:200px; height:30px; line-height:30px; border:1px solid blue; } input { width:200px; height:30px; line-height:30px; border:0; } </style> </head> <body> <table> <tr> <td><input value="1-1" /></td> <td><input value="1-2" /></td> </tr> <tr> <td><input value="2-1" /></td> <td><input value="2-2" /></td> </tr> </table> <script> function $(el){ return typeof el == 'string' ? document.getElementById(el) : el; } function $t(name, cot){ cot = cot || document; return cot.getElementsByTagName(name); } var arr = $t('input'); for(var i = 0, len = arr.length; i < len; i++){ arr[i].onfocus = function(){ this.style.border = '1px solid red'; this.parentNode.style.border = '0'; } arr[i].onblur = function(){ this.style.border = 'none'; this.parentNode.style.border = '1px solid blue'; } } </script> </body></html> 2楼的方法已经很简单了, 照着那个改就好了.还有,用jquery比不用要简单的多... 用js 如何将一个div内的 <script>xxxxxx</script> 这段语句删除掉 请教关于evt参数。。不解哦。。 我发布了一个bs方式的联机围棋,是虎翼的免费空间,只有9天了 如何关闭帧结构 一个两边漂浮的广告.为何就是不动. 请教大家!!!!!!!! 这人JAVA的计数器怎么改???????? 如何使用Explore 内置对象? 页面中的javascript有错,来不及改了;怎么才能让浏览器的左下脚不不出现错误警告? 请问怎样控制同一id的对象 用正则表达式验证表单问题 根据经纬度如何获取该经纬度的地名
下面这个是用的障眼法
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
<style>
* {
margin:0; padding:0; font-size:14px;
}
table {
margin:100px;
}
td {
width:200px; height:30px; line-height:30px;
border:1px solid blue;
}
input {
width:200px; height:30px; line-height:30px;
border:0;
}
</style>
</head>
<body>
<table>
<tr>
<td><input value="1-1" /></td>
<td><input value="1-2" /></td>
</tr>
<tr>
<td><input value="2-1" /></td>
<td><input value="2-2" /></td>
</tr>
</table>
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
function $t(name, cot){
cot = cot || document;
return cot.getElementsByTagName(name);
}
var arr = $t('input');
for(var i = 0, len = arr.length; i < len; i++){
arr[i].onfocus = function(){
this.style.border = '1px solid red';
this.parentNode.style.border = '0';
}
arr[i].onblur = function(){
this.style.border = 'none';
this.parentNode.style.border = '1px solid blue';
}
}
</script>
</body>
</html>
还有,用jquery比不用要简单的多...