我想在这样的表格:
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;" id="PowerTable">
<tr onmouseout="this.bgColor='#FFFFFF'" id="k_0" ondblclick="tr_ondblclick('k_0');" >
<td width="30%" height="22" class="t_1" style="word-break:break-all;overflow:hidden;" >t</td>
<td width="34%" class="t_2">r</td>
</tr>
<tr onmouseout="this.bgColor='#FFFFFF'" id="k_1" ondblclick="tr_ondblclick('k_1');" >
<td width="30%" height="22" class="t_1" style="word-break:break-all;overflow:hidden;" >3</td>
<td width="34%" class="t_2">45</td>
</tr>
<tr>
<td width="30%" height="22" class="t_1"> </td>
<td width="34%" class="t_2"> </td>
</tr><tr>
<td width="30%" height="22" class="t_1"> </td>
<td width="34%" class="t_2"> </td>
</tr>
</table>点击后,提示错误:
消息: 'parentNode.childNodes' 为空或不是对象
行: 134
字符: 19
代码: 0
URI: http://localhost/oa/js/js.js这是我使用的方法:
//表格双击变色-------
function tr_ondblclick(k)
{
for(var i=0;i<k.parentNode.childNodes.length;i++)
{
k.parentNode.childNodes[i].style.backgroundColor='#FFFFF';
}
k.style.backgroundColor='#cecece';
} 请问那里有错了?
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed;" id="PowerTable">
<tr onmouseout="this.bgColor='#FFFFFF'" id="k_0" ondblclick="tr_ondblclick('k_0');" >
<td width="30%" height="22" class="t_1" style="word-break:break-all;overflow:hidden;" >t</td>
<td width="34%" class="t_2">r</td>
</tr>
<tr onmouseout="this.bgColor='#FFFFFF'" id="k_1" ondblclick="tr_ondblclick('k_1');" >
<td width="30%" height="22" class="t_1" style="word-break:break-all;overflow:hidden;" >3</td>
<td width="34%" class="t_2">45</td>
</tr>
<tr>
<td width="30%" height="22" class="t_1"> </td>
<td width="34%" class="t_2"> </td>
</tr><tr>
<td width="30%" height="22" class="t_1"> </td>
<td width="34%" class="t_2"> </td>
</tr>
</table>点击后,提示错误:
消息: 'parentNode.childNodes' 为空或不是对象
行: 134
字符: 19
代码: 0
URI: http://localhost/oa/js/js.js这是我使用的方法:
//表格双击变色-------
function tr_ondblclick(k)
{
for(var i=0;i<k.parentNode.childNodes.length;i++)
{
k.parentNode.childNodes[i].style.backgroundColor='#FFFFF';
}
k.style.backgroundColor='#cecece';
} 请问那里有错了?
$(".t_1").dblclick(function(){
$(this).css("background", "red");
});
$(".t_2").dblclick(function(){
$(this).css("background", "green");
});用jquery多简单,你的parentNode.childNodes和本身没有区别,所以会乱的
加了都是提示有错误
我的是IE8,,是不是IE不支持这种方式?
是不是IE不支持这种方式?