html - How can I make Javascript target the month? -


okay, theoretical me, have no code help. saying :)

i wondering since possible, or @ least have seen been done before, make if statements time i.e. if (time>20) possible months? or did example mention (which found on w3schools.com) use variable without telling me haha.

what i'm looking if statement (hopefully simple) resembles if(month==1) { //incorrect script follows goto(id);};

that example hideous function self not i'm looking for.

i curious , couldn't find anywhere didn't have page worth of code that, me, looks simple in times we're in. i'll experiment code until can tell me. thank time : )

--------------------update!-----------------

i started working on it. , not working me. tried. idea when open or style.display="block"; div of mine, automatically calls current month show people events happening month.

    var = new date(); var month = now.getmonth();  var jan = document.getelementbyid("january"); var feb = document.getelementbyid("february"); var mar = document.getelementbyid("march"); var apr = document.getelementbyid("apri"); var may = document.getelementbyid("may"); var jun = document.getelementbyid("june"); var jul = document.getelementbyid("july"); var aug = document.getelementbyid("august"); var sep = document.getelementbyid("september"); var oct = document.getelementbyid("october"); var nov = document.getelementbyid("november"); var dec = document.getelementbyid("december");  var janhub = document.getelementbyid("janhub"); var aughub = document.getelementbyid("aughub");  function viewevents (){         eventshub.style.display="block";         mainbo.style.display="none";         calender();             };  function eventsx(){             eventshub.style.display="none";             mainbo.style.display="block";};  function calender() {     if (month==0) {         jan.setattribute("class", "current");         janhub.style.display="block";     }else if (month==7) {         aug.setattribute("class", "current");         aughub.style.display="block";};      }; 

obviously made code see test not have ifs each month , etc.

------------------------update-----------------

this code works, don't know if else needs feel free plunder it. it's pretty cool (to me anyways).

var = new date(); var month = now.getmonth();  if (month == 0)     console.log('january');  if (month >= 2)     console.log('march-december'); 

or simply

if((new date()).getmonth() == 11)     console.log('december'); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -