<script language="javascript">
function change(){
this.style.backgroundColor="#C1EDFF";
this.style.fontSize="15px";
} //改变td的背景色 function rollBack(){
this.style.backgroundColor="#FFFFFF";
this.style.fontSize=null;
} //恢复td的背景色 function makeTable(){
var curTable=document.getElementById("table");
curTable=curTable.lastChild;
if(curTable.childNodes.length <3){
for(var trcount=0;trcount <5;trcount++){
var tr=document.createElement("tr");
for(var tdcount=0;tdcount <7;tdcount++){
var td=document.createElement("td");
td.id="td"+trcount.toString()+tdcount.toString();
td.onmouseover=change;
td.onmouseout=rollBack;
td.innerText=trcount.toString()+tdcount.toString();
tr.appendChild(td);
}
curTable.appendChild(tr);
}
}
} //生成table,并且使td的id分别等于td00/td01……td12……td26,到六转0
</script> 表格
<input type="button" onclick="makeTable()" value="make table"/> <br />
<table width="500" height="300" id="table" class="calendar">
<tr> <td colspan="7"> <select id="year" onchange="switchDate()"> </select> <select id="month" onchange="switchDate()"> </select> </td> </tr>
<tr> <td>日 </td> <td>一 </td> <td>二 </td> <td>三 </td> <td>四 </td> <td>五 </td> <td>六 </td> </tr>
</table>
能不能再问一个啊
那我怎么获得我create出来的td的id啊?那些id是不是相同的?