html - 如何在一周中的特定日期和特定时间显示 div 内容?
问题描述
寻找在一周中的特定时间和日期显示 div 的解决方案。我已经找到了一些东西,但我不知道如何修改它以在特定日期和时间显示 html 内容: - 周一 - 周四,从 10:00 到 22:30 - 周五 - 周六,从 10:00 到 24:30 - 周日, 从 11:00 到 21:30
<script type="text/javascript">
function ShowOnTime(from, to, element){
var a = new Date();
var now = a.getHours(); //local hours. For GMT use .getUTCHours()
if( now < from || now > to ){
$(element).html("<br><h4>We are currently unable to process this order. </ h4> <p> Order can be placed only in: <ul><li>Monay - Thursday, from 10:00 to 22:30 </li> <li>Friday - Saturday, from 10:00 to 24:30 </li> <li> Sunday, from 11:00 to 21:30</li></ul>");
}else{
$(element).show();
}
}
$(document).ready(function(){
ShowOnTime(12,24,"#hide");
});
</script>
<div id="hide">
<div>
Link to proceed order, is visible only on specific hours and day of the week</div>
</div>
解决方案
推荐阅读
- rest - Microsoft Graph:假设 plannerTask.id 和 plannerTaskDetails.id 始终相同是否安全?
- java - Android 应用程序:当我一次性从 API 中放入大约 300 条记录时,RecyclerView 挂起
- sinon - Loopback 4:测试Sinon和注入的问题
- python - 如何使用 pipenv 指定在哪里创建虚拟环境?
- redux - 我试图用 redux 获取输入,一切都很好,但我不知道如何获取输入值
- java - 是什么导致了这个异常:java.lang.NoSuchFieldException?
- yesod - Yesod Hamlet 通过用双引号替换单引号来破坏 HTML
- c# - 如何在asp.net的gridview中将两个资源值合二为一
- gruntjs - WebP 的 Grunt 文件夹中的变量名称
- javascript - 此页面未正确加载 Google 地图。有关技术细节,请参阅 JavaScript 控制台。在 2 秒内显示地图之前