Change the image based on the time

Saratvaddilli
Posted by Saratvaddilli under JavaScript category on | Points: 40 | Views : 812
<script language="JavaScript" type="text/javascript">  
var now = new Date();
var hour = now.getHours();

if (hour <=11){
var TimeofDay = "<img src="images/Pic1.jpg">"
}else if(hour > 11 && hour <= 17){
var TimeofDay = "<img src="images/Pic2.jpg">"
}else if(hour > 17){
var TimeofDay = "<img src="images/Pic3.jpg">"
}
</script>

<script>
document.write(TimeofDay)
</script>

Comments or Responses

Login to post response