代码之家  ›  专栏  ›  技术社区  ›  ferralucho

Hightlight jquery datepicker标头选定的星期几

  •  1
  • ferralucho  · 技术社区  · 7 年前

    我想在jquery datepicker标题中突出显示一周中选定的日期(Su、Mo、Tu、We、Th、Fr、Sa)。请注意下一幅图像中的标题(Tu为粗体):

    highlight day in datepicker header

    天标题部分的HTML如下所示:

    enter image description here

    我需要使用datepicker的什么函数或属性高亮显示标题中选定的日期?非常感谢。

    1 回复  |  直到 7 年前
        1
  •  1
  •   Sandwell    7 年前

    对此没有选择。 如果需要,可以使用我的示例作为解决方法:

      $('#js-date').datepicker().on('changeDate', function(ev) {
        var currentDate = new Date($('#js-date').val());
        $('.datepicker-days th.dow').removeClass('active')
        switch (currentDate.getDay()) {
          case 0:
            $('th.dow').eq(0).addClass('active');
            break;
          case 1:
            $('th.dow').eq(1).addClass('active');
            break;
          case 2:
            $('th.dow').eq(2).addClass('active');
            break;
          case 3:
            $('th.dow').eq(3).addClass('active');
            break;
          case 4:
            $('th.dow').eq(4).addClass('active');
            break;
          case 5:
            $('th.dow').eq(5).addClass('active');;
            break;
          case 6:
            $('th.dow').eq(6).addClass('active');
            break;
        }
      });
    

    https://jsfiddle.net/Sandwell/8qacnzd9/40/