日期:2014-05-16  浏览次数:20395 次

[新手]怎么使一个对象上的触发事件改变另外一个对象的值?
js新手做一个按钮,将鼠标事件设在了table上,而控制按钮样式的class设在td上,请问这个鼠标事件该如何控制td上的class改变?
代码如下
-----------------------------
<table   border= "0 "   cellpadding= "0 "   cellspacing= "0 "   class= "fBtnSize "   onmouseover= "btnover(); "   onmouseout= "btnout(); "   onmousedown= "btndown(); "   onmouseup= "btnup(); ">
    <tr>
        <td   align= "center "   class= "fBtnABl "> </td>
        <td   align= "center "   class= "fBtnAB "> 确认 </td>
        <td   align= "center "   class= "fBtnABr "> </td>
    </tr>
</table>
------------------------------
btnover(),btnout(),btndown(),btnup()这组函数该如何获取几个td上的对象?

------解决方案--------------------
<table id= "table1 " border= "0 " cellpadding= "0 " cellspacing= "0 " class= "fBtnSize " onmouseover= "btnover(); " onmouseout= "btnout(); " onmousedown= "btndown(); " onmouseup= "btnup(); ">
<tr>
<td align= "center " class= "fBtnABl "> </td>
<td align= "center " class= "fBtnAB "> 确认 </td>
<td align= "center " class= "fBtnABr "> </td>
</tr>
</table>
<script language= "javascript ">
var obj=document.getElementById( "table1 ");
var obj_tr=obj.rows(0); //第一行
for (i=0;i <obj_tr.childNodes.length;i++)
alert(obj_tr.childNodes(i).className);
</script>