<div class="class_body">
<table cellSpacing=0>
<script language="javascript" type="text/javascript">
document.write("<tr>");
titlehaed(0);
writralldaylong();
document.write("</tr>"); </script>
</table></div><div class="class_content">
<table cellSpacing=0 >
<script language="javascript" type="text/javascript">
for (j=0;j<24;j++) { document.write("<tr>");
titles(j);
writeTdone(j); document.write("</tr><tr>");
writeTdtwo(j); document.write("</tr>");
}
</script>
</table></div>function writeTdone(rowNum)
{ for(i=0; i<7; i++)
{ document.write('<td class="class_td_activity" onclick="clicks('+i + ',' + rowNum +')"></td>');
}
}
function writeTdtwo(rowNum)
{ for(i=0; i<7; i++)
{ document.write('<td class="class_td_activityone" onclick="clicks('+i + ',' + rowNum +')"></td>');
}
}
function titles(titleNum)
{
var titleText = new Array("上午12点","上午1点","上午2点","上午3点","上午4点","上午5点","上午6点","上午7点","上午8点","上午9点","上午10点","上午11点","下午12点","下午1点","下午2点","下午3点","下午4点","下午5点","下午6点","下午7点","下午8点","下午9点","下午10点","下午11点"); document.write('<th rowspan="2" class="class_th_time">'+titleText[titleNum]+'</th>');
}function sky(z)
{
z = z+1;
alert("周" + z);
}function writralldaylong ()
{ for(z=0; z<7; z++)
{ document.write('<td class="class_td_content"onclick="sky('+z+')"></td>');
}
}function titlehaed(titleNum)
{
var headText = new Array("GMT+08"); document.write('<th class="class_th_alldaylong">'+headText[titleNum]+'</th>');
}我是用JS写出的一个表格 7天一周那么怎么用JS在这个7个格子里面每个添加一个ID呢?也是用JS写的请问 用for写出来
2 回答
噜噜哒
TA贡献1784条经验 获得超7个赞
懒得看你代码 ... 标题的问题回答如下 ...
<div>Hello World</div><script type="text/javascript">var div = document.getElementsByTagName("div")[0]; div.setAttribute("id","yourdiv");alert( document.getElementById("yourdiv").innerHTML );</script>
红颜莎娜
TA贡献1842条经验 获得超12个赞
这是我根据我对你的意图的猜测得出的结论
function titles(titleNum) { var titleText = new Array("上午12点","上午1点","上午2点","上午3点","上午4点","上午5点","上午6点","上午7点","上午8点","上午9点","上午10点","上午11点","下午12点","下午1点","下午2点","下午3点","下午4点","下午5点","下午6点","下午7点","下午8点","下午9点","下午10点","下午11点"); document.write('<th rowspan="2" class="class_th_time" id="ID"'+titleNum+'>'+titleText[titleNum]+'</th>'); }
添加回答
举报
0/150
提交
取消