错误在哪里啊?
为什么一直在var cell = event.srcElement.parentElement; 处报错啊,怎么修改,谢谢了<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo_For_Wang</title><script type="text/javascript">
function changeColor1(title){
var t=document.getElementById("table2").childNodes.item(0); for(var i=0;i< t.childNodes.length;i++)
{
for(var j=0;j<t.childNodes(i).childNodes.length;j++)
{
t.childNodes(i).childNodes(j).bgColor="white";
}
}
var cell = event.srcElement.parentElement;
cell.bgColor = "red";
alert(title);
}
</script></head><body><table border="1px" id="table2">
<tr>
<td id="td1">
<a href="javascript:changeColor1('111')">google</a>
</td>
<td id="td2">
<a href="javascript:changeColor1('222')">baidu</a>
</td>
<td id="td3">
<a href="javascript:changeColor1('333')">douban</a>
</td>
<td id="td4">
<a href="javascript:changeColor1('444')">renren</a>
</td>
</tr>
</table></body>
</html>
为什么一直在var cell = event.srcElement.parentElement; 处报错啊,怎么修改,谢谢了<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo_For_Wang</title><script type="text/javascript">
function changeColor1(title){
var t=document.getElementById("table2").childNodes.item(0); for(var i=0;i< t.childNodes.length;i++)
{
for(var j=0;j<t.childNodes(i).childNodes.length;j++)
{
t.childNodes(i).childNodes(j).bgColor="white";
}
}
var cell = event.srcElement.parentElement;
cell.bgColor = "red";
alert(title);
}
</script></head><body><table border="1px" id="table2">
<tr>
<td id="td1">
<a href="javascript:changeColor1('111')">google</a>
</td>
<td id="td2">
<a href="javascript:changeColor1('222')">baidu</a>
</td>
<td id="td3">
<a href="javascript:changeColor1('333')">douban</a>
</td>
<td id="td4">
<a href="javascript:changeColor1('444')">renren</a>
</td>
</tr>
</table></body>
</html>
解决方案 »
- document.onload,window.onload,body.onload,document.onready的区别
- 页面打印问题,求救~~
- 上传多个附件
- javascript 如何验证用户
- 求一段JS代码,框架中打开超链方面的技术
- 怎样移除<select>标签中的<option>元素啊?急!
- 想传递数组。想找出总数??在线等
- JQuery Uploadify隐藏浏览按钮后,通过JS触发Uploadify的Click事件,不能上传文件
- 在没提交表单的情况下 如何动态获取表单的值呢?
- 求如何封装让相同地方使用,但涉及值不一样。。
- Jquery中下来列表selectbox() ,无法发生onchange事件
- javascript报错问题
event 为 nullvar cell = event.srcElement.parentElement;
这句当然出错了
哥们能不能不改变<a href="javascript:changeColor1('444')">renren</a>
只改变js让程序可用啊