Javascript add different text to each minute of hour

Topics related to client-side programming language.
Post questions and answers about JavaScript, Ajax, or jQuery codes and scripts.
User avatar
Posts: 227
Location: Holland Rotterdam

Javascript add different text to each minute of hour

Hello Coursesweb I`m unknown with javascripts ????

I would like to add function minutes to this script
on each minute an diferent text added to the hour

Hope you can help me out....

Code: Select all

day = new Date() 
hr = day.getHours() 

if (hr == 1) document.write("<font face='Verdana' color='blue' size='5'>After one .... not yet to bed?</font>") 
if (hr == 2) document.write("<font  face='Verdana' color='blue'   size='5'>After two.... Wouldn`t you even go to sleep?</font>") 

Try the following script.

Code: Select all

<div id='addtxtmin' style='color:#00d; font-size:20px; font-weight:700'></div>
const txt_min =[
'After one .... not yet to bed?',
'After two.... Wouldn`t you even go to sleep?',
'Minute 3',
'Minute 4',
'Minute 5'
var addtxtmin = document.getElementById('addtxtmin');

function addTxtMin() {
  var ddate=new Date()
  var min = ddate.getMinutes();
  var txt = txt_min[min] ? txt_min[min] : 'Default text: Minute '+ min;
  addtxtmin.innerHTML = txt;

Similar Topics