简体   繁体   中英

how hide/show div depending on days using javascript or php?

i want to show div only Sunday Monday,Tuesday,Wednesday,Thursday

and hide it in,Friday,Saturday

this my code:

<script>
function newep(){
var fecha = new date();
var day = fecha.getDay();
if(day == 4 || day == 5){
 console.log("show nothing");
}else if(day == 6 || day == 3){
 console.log("New Episodde");
}
}
</script>
<div onload="newep()">here the output</div>

I got that out of your code:

<script>
function newep(node)
{
var fecha = new date();
var day = fecha.getDay();
if(day == 4 || day == 5){
 node.hidden=true;
 //or : node.disabled=true
}
}
</script>

```<div onload="newep(this)">here the output</div>```

with php you could do:

<?php
$date_number=date('w');
if($date_number==5 || $date_number==6)
{
 ?>
 //your div
 <?php
}
?>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM