如何在一周中的特定日期和特定时段显示div内容?

时间:2018-04-25 09:55:50

标签: html date hide show

寻找在特定时段和星期几显示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/

0 个答案:

没有答案