getDate with Jquery Datepicker

后端 未结 5 1364
礼貌的吻别
礼貌的吻别 2020-12-05 14:45

i am trying to get date from my implementation of jquery date picker, add it to a string and display the resulting image in my div. Something however is just not working. Ca

5条回答
  •  天涯浪人
    2020-12-05 15:21

    I think you would want to add an 'onSelect' event handler to the initialization of your datepicker so your code gets triggered when the user selects a date. Try it out on jsFiddle

    $(document).ready(function(){
        // Datepicker
        $('#datepicker').datepicker({
            dateFormat: 'yy-mm-dd',
            inline: true,
            minDate: new Date(2010, 1 - 1, 1),
            maxDate:new Date(2010, 12 - 1, 31),
            altField: '#datepicker_value',
            onSelect: function(){
                var day1 = $("#datepicker").datepicker('getDate').getDate();                 
                var month1 = $("#datepicker").datepicker('getDate').getMonth() + 1;             
                var year1 = $("#datepicker").datepicker('getDate').getFullYear();
                var fullDate = year1 + "-" + month1 + "-" + day1;
                var str_output = "



    "; $('#page_output').html(str_output); } }); });

提交回复
热议问题