根据时间更新div内容 [英] Updating div content according to time
本文介绍了根据时间更新div内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要根据当前时间更新我的Header (h1)
。例如,在上午7:45到上午8:00
'Current Event'应该变为' Event1
',在上午8:00至上午8:15
它应该变为' Event2
'等等。
I need to update my Header (h1)
according to the current time. For example at 7:45am to 8:00am
'Current Event' should change to 'Event1
', at 8:00am to 8:15am
it should change to 'Event2
' and so on.
<html>
<head>
<title>ShriTeq 2015</title>
</head>
<body>
<center>
<img src = "image.png" width = "25%" height = "auto"/>
<h1 id = "ce" style="font-weight:lighter; font-family: 'Raleway', sans-serif; font-size:70px;">Current Event</h1>
</center>
</body>
</html>
推荐答案
试试;
Try;
function headerChange(){
var d = new Date();
var m = d.getMinutes();
var h = d.getHours();
if(h == 7 && m>=45){
$("#ce").html("Event1");
}else if(h == 8 && m<=15){
$("#ce").html("Event2");
}
}
headerChange();
setTimeout(headerChange, 1000);
希望这可以帮助您
这篇关于根据时间更新div内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文