How to highlight specific dates in bootstrap datepicker?

后端 未结 5 1289
广开言路
广开言路 2021-02-20 10:19

I am using bootstrap datepicker.I need to highlight some random dates.

For Example:

I need to highlight the dates like 1,3,8,20,21,16,26,30. Could you please tel

5条回答
  •  盖世英雄少女心
    2021-02-20 11:10

    The Blog post here explaining how it can achieve using Bootstrap Datetimepicker.

    Basically using the events show, update and change the date need to be highlighted.

    $('#datetimepicker').on('dp.show', function(e){
      highlight()
    })
    $('#datetimepicker').on('dp.update', function(e){
     highlight()
    })
    $('#datetimepicker').on('dp.change', function(e){
        highlight()
    })
    
    function highlight(){
     var dateToHilight = ["04/19/2019","04/20/2019","04/30/2019"];
     var array = $("#datetimepicker").find(".day").toArray();
     for(var i=0;i -1) {
           array[i].style.color="#090";
           array[i].style.fontWeight = "bold";
        } 
     }
     }
    

    For more information see the blog

    Reference:

    https://scode7.blogspot.com/2019/04/here-is-code-function-hilight-var.html

提交回复
热议问题