首页 > 解决方案 > 如何在一周中的特定日期和特定时间显示 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>

https://jsfiddle.net/Arczix/hgt0ahmo/

标签: htmldatehideshow

解决方案


推荐阅读