I was wonder if anyone can tell me why this isn't working? I am trying to switch display of div.
function testDatum(){
var vandaag = new Date();
var eindDatum = new Date('04/15/2018');
if (vandaag > eindDatum){
document.getElementById('Div1').style.display = 'none';
}
else {
document.getElementById('Div2').style.display = 'none';
}
}
The code works....
function testDatum(){ var vandaag = new Date(); var eindDatum = new Date('05/15/2018'); if (vandaag > eindDatum){ document.getElementById('Div1').style.display = 'none'; } else { document.getElementById('Div2').style.display = 'none'; } } testDatum()
<div id="Div1">Div1</div> <div id="Div2">Div2</div>
What you have written, It's absolute current but you didn't declare the function. So, You didn't get any result.
declare function now you get result. testDatum();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.