分别alert innerHTML看看是啥
解决方案 »
- 高手们,怎样在不修改页面的情况下让所有页面引用同一个JS?
- FireFox下怎么判断mousedown是点击在div的滚动条上而不是div内容区域中?
- 奋进中的javascript小仓鼠
- if (!c4csel.compare(frameWindow.document)) return true;
- 调用sohu星座数据可否实现?【内附sohu星座里的JS文件】
- 难解决:如何控制form.target='_blank'打开的空白窗口的位置
- 还是关于获取<font>id的问题,请问有什么错误呢
- 这处格式,为什么火狐提示是:
- 请大伙进来看看?
- 防止别人窃取网站信息
- 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>