<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>日历</title> <style type="text/css"> #table1 { border:1px solid black; width:250px; height:250px; } #table1 td{ border:1px solid black; text-align: center; padding:10px; width:80px; height:80px; } #div1 { background:#ccc; width:200px; height:420px; float:left; } </style> <script type="text/javascript"> window.onload=function (){ var oTd=document.getElementsByTagName('td'); var oDiv=document.getElementById('div1'); var arr=[ "111", "222", "333", "444", "请问weq", "cewdw", "wswsws", "zxczxc", "wswsws", "qaqaqa", "dedede", "xsce", ] for (var i=0;i<oTd.length;i++){ oTd[i].index=i; oTd[i].onmouseover=function (){ this.style.backgroundColor="black"; this.style.color="white"; } oTd[i].onmouseout=function (){ this.style.background=""; this.style.color=""; } oDiv.innerHTML=arr[this.index]; } } </script> </head> <body> <table id="table1" > <tr> <td>a</td> <td>b</td> <td>c</td> </tr> <tr> <td>d</td> <td>e</td> <td>f</td> </tr> <tr> <td>g</td> <td>h</td> <td>i</td> </tr> <tr> <td>j</td> <td>k</td> <td>l</td> </tr> <div id="div1"></div> </table> </body> </html>
但是为啥鼠标移入之后左边会显示undefined? 求救求救啊困惑好久啦
joffyzou
慕粉3799017
慕沐9665835
慕的地6079101
超级巨浪大切