javascript - 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>
解决方案
我从你的代码中得到了这个:
<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
}
?>
推荐阅读
- c++ - 如何初始化具有已知参数的对象,该对象是 C++ 中类的成员?
- python - 我在从相互 .py 文件中导入时遇到问题
- discord.js - 试图让我的机器人在 7 小时后删除消息
- python - 如何加入子图窗口?
- ios - NativeScript - Angular ios 状态栏样式
- mysql - Mysql子查询建议
- java - 如何在 android 应用程序中显示我的动画 svg 文件?
- javascript - 如何在 React Hooks 中应用输入验证
- python - 从 json 输出中删除一个字符
- vaticle-typedb - 使用 Workbase 可视化架构