问题简单描述:
<div class="helloTime">
<ul class="hello_le">
<li class="hello_le2">
<c:if test="${user.identityId == 1}">
<p class="hello_time">HI 厂家您好</p>
<span class="welc">欢迎来到俱合网<span>
</c:if>
<c:if test="${user.identityId == 2}">
<p class="hello_time">HI 买家您好</p>
<span class="welc">欢迎来到俱合网<span>
</c:if>
<c:if test="${user.identityId == null}">
<p class="hello_time" id="overTime">a</p>
<span class="welc">欢迎来到俱合网<span>
</c:if>
</li>
<li class="hello_rig">
<img class="xiaolu" src="${ctx}/common/images/titlelu1.png">
</li>
<ul>
</div>
以下是js
(function(){
var hh = document.getElementById("overTime");
var now = new Date();
var hours =now.getHours();
if(hours>=12){
hh.innerHTML = "HI,下午好";
}else{
hh.innerHTML ="HI,上午好";
}
})()
总是报错Uncaught TypeError: Cannot set property 'innerHTML' of null
if(hh!=null)
{
if(hours>=12){
hh.innerHTML = "HI,下午好";
}else{
hh.innerHTML ="HI,上午好";
}
}试试呢
谢谢。真的不报错了呢,这是为什么呀????