0

I need some help with a javascript

I need to create a script that checks a time range (costa rica time) and then displays the following:

  1. a static image from 7pm to 5am

  2. a video streaming from 5.01am to 6.59pm

I prepared this solution but I don't know how to show the static image and the streaming:

<script type="text/javascript">    

var d = new Date();
var n = d.getHours(); //get the current local time's hour in military time (1..23)

//If the time is greater than or equal to 7pm or less than or equal to 7am
if (n >= 19 || n <= 5) 
{       
  show image
}
else 
{
   stream video
}

Thanks

Erik
  • 2,316
  • 9
  • 36
  • 58
Mariano
  • 17
  • 3
  • Possible duplicate of [Programmatically change the src of an img tag](http://stackoverflow.com/questions/11722400/programmatically-change-the-src-of-an-img-tag) – Madhawa Priyashantha Jul 13 '16 at 17:58

1 Answers1

0

If you use Jquery, You could do a one of two things (among others but these I find to be the simplest):

  • Show and hide the Elements $("videoselector").show();$("imageselector").show()
  • You could use .append() $("body").append("<img src='src'/>")

These both have js equivalents as well

  • document.getElementById("videoElementID").style.display = "none";
  • document.createElement("IMG");

Hope those help, please ask if you have any questions. I'll be happy to elaborate on any of these if needed.

The Dark Knight
  • 695
  • 4
  • 10