childNodes 到底取到的什么东西呀1!为什么搞不清楚呀1! 分别alert innerHTML看看是啥 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var table = document.getElementById("table1");var tds = table.getElementsByTagName("td");--------------------------先了解table的结构,你的table 应该像下面那样写<table><tbody><tr><td>td1</td></tr></tbody></table>然后table 先找到tbody再找到tr才能找到td <script language="javascript">function init(){ var table = document.getElementById("table1"); var tds = table.getElementsByTagName("td"); for(var i = 0 ; i < tds.length ;i++) { note = tds[i].children; //alert(tds[i].children.length); tds[i].onclick = function() { if(this.children[0].id.indexOf("userName") != -1) { this.children[0].style.display = "none"; this.children[1].style.display = ""; } } tds[i].children[1].onblur = function() { this.parentElement.children[0].style.display = ""; this.parentElement.children[1].style.display = "none"; this.parentElement.children[0].innerText = this.parentElement.children[1].value; } }}window.onload = init;</script> 关于jquery框架的一个问题,知道的来说下 显示一个数500ms,然后消失,接着再显示一个数 JavaScript调用ActiveX控件两种方法有无区别 请问如何将在js中传一个参数给另一个页面,并得到其返回值?(在线等待,解决就结帖) 请教: 数组问题SOS javascript提示“错误:没有权限”是怎么回事? Help在线等待 怎么得到<textarea>可见部分的内容 [jsp]投票网站关于选项增加删除的问题 tds[i], 为什么用变量不行呀!!固定写死成1或0就可以呀!!什么原因,求助 请问关于javascript控制div层显示的问题
var tds = table.getElementsByTagName("td");
--------------------------
先了解table的结构,
你的table 应该像下面那样写
<table>
<tbody>
<tr>
<td>td1</td>
</tr>
</tbody>
</table>
然后table 先找到tbody再找到tr才能找到td
function init()
{
var table = document.getElementById("table1");
var tds = table.getElementsByTagName("td");
for(var i = 0 ; i < tds.length ;i++)
{
note = tds[i].children;
//alert(tds[i].children.length);
tds[i].onclick = function()
{
if(this.children[0].id.indexOf("userName") != -1)
{
this.children[0].style.display = "none";
this.children[1].style.display = "";
}
}
tds[i].children[1].onblur = function()
{
this.parentElement.children[0].style.display = "";
this.parentElement.children[1].style.display = "none";
this.parentElement.children[0].innerText = this.parentElement.children[1].value;
}
}
}
window.onload = init;
</script>