为了账号安全,请及时绑定邮箱和手机立即绑定

document.getElementById(tag)错误

/ 猿问

document.getElementById(tag)错误

BIG阳 2018-12-06 17:03:53
 。。。
			<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”对象为什么得不到呢?
查看完整描述

2 回答

?
郎朗坤

TA贡献1684条经验 获得超8个赞

layerCalendar和layerCalender是不一样的……
查看完整回答
反对 回复 2019-01-21
?
ITMISS

TA贡献1648条经验 获得超9个赞

楼上正解!
查看完整回答
反对 回复 2019-01-21
  • 2 回答
  • 0 关注
  • 366 浏览
我要回答

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信