jquerydatepickeronselect

problem with jquery datepicker onselect


Following the basic onSelect spec on the jquery site I tried the following code:

<!DOCTYPE html>
<html>
<head>
  <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
  <script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
  <script type="text/javascript">
  $(document).ready(function(){
    $("#datepicker").datepicker();


$('#datepicker').datepicker({
   onSelect: function(dateText, inst) { alert("Working"); }
});



  });

  </script>
</head>
<body style="font-size:62.5%;">

<div type="text" id="datepicker"></div>

</body>
</html>

And can't get it to work! Originally been trying to get a more complicated thing to work but the onSelect was just not working so I went back to basics and still don't work, anyone any idea what I'm doing wrong??


Solution

  • You might try removing the second $("#datepicker").datepicker() immediately above that line, leaving:

    $(document).ready(function(){
        $('#datepicker').datepicker({ onSelect: function(dateText, inst) { alert("Working"); } });
    });