猿问

document.getElementById(tag)错误

 。。。
			<tr align="center">
                                                        <td>
                                                            <span id="layerCalender"></span>
                                                        </td>
                                                    </tr>
。。。
<script language="javascript" type="text/javascript">
<!--
var dayArray=new Array("日","一","二","三","四","五","六");
var monthArray=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var stringTable="<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" style=\"align:center;border-color:#8F8FAF;height:100%\" width=\"100%\"><tr style=\"background-color:#ffffff;align:center\">";
for (var i=0; i<dayArray.length; ++i)
{
	stringTable+="<td class=\"tdclass\"><font color=\"#993333\"><b>"+dayArray[i]+"</b></font></td>";
}
stringTable+="</tr>";
function setValue(tag, str)
{
	document.getElementById(tag).innerHTML=str;
}
function showTime()
{
	var today=new Date();
	var currentYear=today.getFullYear()
	if (((currentYear%4==0)&&(currentYear%100!=0))||(currentYear%400==0))
		monthArray[1]=29;
	var allDays=monthArray[today.getMonth()];
	var currentWeek=today.getDay();
	var currentDay=today.getDate();
	var i=currentDay%7-currentWeek;
	var threshold=(7+i)%7;
	var isEnd=false;
	var stringAll=stringTable;
	while (true) {
		if (isEnd) {
			stringAll+="<td class=\"tdclass\" style=\"background-color:#EEEEEE\"> </td>";
			if (i % 7==(threshold+6)%7) {
				stringAll+="</tr>";
				break;
			}
		} else {
			if (i % 7==threshold)
				stringAll+="<tr style=\"align:center\">";
			stringAll+=i>0?"<td class=\"tdclass\""+(i==currentDay?" style=\"background-color:#FEA477;color: #FFFFFF\"":"")+"><b>"+i+"</b></td>":"<td class=\"tdclass\" style=\"background-color:#EEEEEE\"> </td>";
			if (i % 7==(threshold+6)%7) {
				stringAll+="</tr>";
				if (i==allDays)
					break;
			}
			if (i==allDays)
				isEnd=true;
		}
		++i;
	}
	stringAll+="</table>";
	setValue("layerYear", currentYear);
	setValue("layerMonth", today.getMonth()+1);
	setValue("layerDay", currentDay);
	setValue("layerWeek", dayArray[currentWeek]);
	setValue("layerCalendar", stringAll);
}
showTime()
// -->
                                                </script>
请问“layerCalender”对象为什么得不到呢?
BIG阳
浏览 577回答 2
2回答

郎朗坤

layerCalendar和layerCalender是不一样的……

ITMISS

楼上正解!
随时随地看视频慕课网APP
我要回答