How to set the date in materialize datepicker

后端 未结 10 1224
长发绾君心
长发绾君心 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:25

    Materialize datepicker is a modified pickadate.js picker.

    Accodging to their API docs, this is how to set the picker:

    1. Get the picker:

    var $input = $('.datepicker').pickadate()
    
    // Use the picker object directly.
    var picker = $input.pickadate('picker')

    1. Set the date:

    // Using arrays formatted as [YEAR, MONTH, DATE].
    picker.set('select', [2015, 3, 20])
    
    // Using JavaScript Date objects.
    picker.set('select', new Date(2015, 3, 30))
    
    // Using positive integers as UNIX timestamps.
    picker.set('select', 1429970887654)
    
    // Using a string along with the parsing format (defaults to `format` option).
    picker.set('select', '2016-04-20', { format: 'yyyy-mm-dd' })

提交回复
热议问题