jQuery datepicker, onSelect won't work

前端 未结 8 1806
死守一世寂寞
死守一世寂寞 2020-12-05 04:09

I can\'t get onSelect working on my jQuery datepicker.

Heres my code:



        
相关标签:
8条回答
  • 2020-12-05 04:30

    The function datepicker is case sensitive and all lowercase. The following however works fine for me:

    $(document).ready(function() {
      $('.date-pick').datepicker( {
        onSelect: function(date) {
            alert(date);
        },
        selectWeek: true,
        inline: true,
        startDate: '01/01/2000',
        firstDay: 1
      });
    });
    
    0 讨论(0)
  • 2020-12-05 04:33

    No comma after the last property.

    Semicolon after alert(date);

    Case on datepicker (not datePicker)

    Check your other uppercase / lowercase for the properties.

    $(function() {
        $('.date-pick').datepicker( {
            onSelect: function(date) {
                alert(date);
            },
            selectWeek: true,
            inline: true,
            startDate: '01/01/2000',
            firstDay: 1
        });
    });
    
    0 讨论(0)
  • 2020-12-05 04:35
    <script type="text/javascript">
        $(function() {
            $("#datepicker").datepicker({ 
                  onSelect: function(value, date) { 
                     window.location = 'day.jsp' ; 
                  } 
            });
        });
     </script>
    
    <div id="datepicker"></div>
    

    I think you can try this .It works fine .

    0 讨论(0)
  • 2020-12-05 04:36

    It should be "datepicker", not "datePicker" if you are using the jQuery UI DatePicker plugin. Perhaps, you have a different but similar plugin that doesn't support the select handler.

    0 讨论(0)
  • 2020-12-05 04:47
    $('.date-picker').datepicker({
                        autoclose : true,
                        todayHighlight : true,
                        clearBtn: true,
                        format: 'yyyy-mm-dd', 
                        onSelect: function(value, date) { 
                             alert(123);
                        },
                        todayBtn: "linked",
                        startView: 0, maxViewMode: 0,minViewMode:0
    
                        }).on('changeDate',function(ev){
                        //this is right events ,trust me
                        }
    });
    
    0 讨论(0)
  • 2020-12-05 04:49

    I have downloaded the datepicker from jqueryui.com/download and I got 1.7.2 version but still onSelect function didn't work. Here is what i had -

    $("#datepicker").datepicker();
    
    $("#datepicker").datepicker({ 
          onSelect: function(value, date) { 
             alert('The chosen date is ' + value); 
          } 
    });
    

    I found the solution in this page -- problem with jquery datepicker onselect . Removed the $("#datepicker").datepicker(); once and it worked.

    0 讨论(0)
提交回复
热议问题