<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<DIV class="time_lbc">
<UL id=index_tab01>
<LI onMouseOver="this.className='b'" onMouseOut="this.className=''">
<span class="cx">XX</span>
<SPAN class="xm">XX</SPAN>
<SPAN class="jie" style="display:none">18:35</span>
<SPAN class="list">XX</SPAN>
<SPAN class="address">XX</SPAN>
</LI>
<LI onMouseOver="this.className='b'" onMouseOut="this.className=''">
<span class="cx">XX</span>
<SPAN class="xm">XX</SPAN>
<SPAN class="jie" style="display:none">20:00</span>
<SPAN class="list">XX</SPAN>
<SPAN class="address">XX</SPAN>
</LI>
<LI onMouseOver="this.className='b'" onMouseOut="this.className=''">
<span class="cx">XX</span>
<SPAN class="xm">XX</SPAN>
<SPAN class="jie" style="display:none">00:05</span>
<SPAN class="list">XX</SPAN>
<SPAN class="address">XX</SPAN>
</LI>
</UL>
</DIV>
<script type="text/javascript">
var myDate = new Date();
var strHours = (myDate.getHours() > 9) ? myDate.getHours() : '0' + myDate.getHours();
var strMinutes = (myDate.getMinutes() > 9) ? myDate.getMinutes() : '0' + myDate.getMinutes();
var data = (strHours + strMinutes);
var arr=document.getElementsByTagName("li");
for(var i=0;i<arr.length;i++){
for(var j=0;j<arr[i].childNodes.length;j++){
if(arr[i].childNodes[j].tagName=="SPAN" && arr[i].childNodes[j].style.display=="none"){
if(parseInt(arr[i].childNodes[j].innerHTML)- data ){ arr[i].style.display="none"}
}
}
}
</script>
这样获取到的时间和系统时间对比怎么会没有效果?比如获取到的时间小于系统时间就不做任何改变,大于系统时间就隐藏LI
------解决方案--------------------
你这个地方是在判断那个是否相等,if判断是会被认为只要非零就算符合,所以大于或小于都会是同一种情况的
------解决方案--------------------
你那不是时间比较,只是字符串相减而已,字符串类型相减结果为NaN,作if判断条件时同false
------解决方案--------------------
<script type="text/javascript">
$(document).ready(function(){
setInterval(function(){
var myDate = new Date();
var hm=parseFloat(myDate.getHours()+("0"+myDate.getMinutes()).slice(-2));
$(".jie").each(function(){
var str=parseFloat($(this).text().replace(":",""));
if(str>hm){