How to set the date in materialize datepicker

后端 未结 10 1223
长发绾君心
长发绾君心 2020-12-05 09:36

I am using materializecss.com Datepicker. When i try to set date with jquery, the date doesn\'t get set. Here is my Code :-

// Materialize Date Picker
    wi         


        
10条回答
  •  -上瘾入骨i
    2020-12-05 10:36

    If you are using angular, or something similar, in order to manage your web application and you are not able to instance the Datepicker object, according to the materialize documentation, using jQuery you can refer to these methods of the object:

    $('.datepicker').datepicker('setDate', new Date());
    

    In the first parameter, in this case setDate, you may specify the method name that you are about to use. In the second parameter, in this case new Date(), you will pass the value to the function (if any).

    In the example, that line will update the date of all datepickers with the class .datepicker to today.

提交回复
热议问题