如何隐藏/显示div取决于使用javascript或php的日子?



我想只显示div Sunday Monday,Tuesday,Wednesday,Thursday

和隐藏在,星期五,星期六

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>

我从你的代码中得到的:

<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>```

在PHP中你可以这样做:

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

最新更新