js判断页面日期大小
程序员文章站
2022-03-04 17:47:15
...
[size=x-large][color=red][b]js判断页面日期大小 [/b][/color][/size]
[size=medium][color=red][b]js:[/b][/color][/size]
[size=medium][color=red][b]js:[/b][/color][/size]
<script type="text/javascript"><!--
function getTdValue(){
var txt=document.getElementsByName("t");
var today = new Date();
for(var i = 0;i<txt.length;i++){
//alert(txt[i].innerHTML);
//alert(txt.length);
var hzdate = txt[i].innerHTML;
//var d = "2011-09-21";
var hzdate1 = hzdate.replace(/[^\d]+/g,'')*1;
var nowdate = (today.getFullYear().toString()+getM(today)+today.getDate().toString())*1;
//alert(d1<nowdate);
if(hzdate1<nowdate){
txt[i].innerHTML="已过期";
}
}
}
function getM(today){
if(today.getMonth()<10){
return '0'+(today.getMonth()+1).toString();
}else{
return (today.getMonth()+1).toString();
}
}
</script>
html:
<body onload="getTdValue();">
<table id="tab">
<s:iterator value="list" id="el" status="i">
<tr>
<td id="<s:property value="#i.count" />" name="t">
<s:property value="#el" />
</td>
</tr>
</s:iterator>
</table>
</body>
上一篇: Ext 监听页面窗口大小