Datepicker onSelect not working

爱⌒轻易说出口 提交于 2019-12-13 05:42:12

问题


I have the function below that doesn't seem to work and could do with a little help please. The function basically adds 30 days to the date selected with the datepicker.

$('#datepicker').datepicker({
   onSelect: function(dateText, inst) { 

       var date = new Date(dateText);
       date.setDate(date.getDate() + 30);
       date.format('mm/dd/yy');

       alert(date)
   }
});

I cant see where I am going wrong. When a date is selected it is adding a empty anchor to the address bar URL, if is helps.

Thanks.


回答1:


The problem is that date.format('mm/dd/yyy') is blowing up.

Examples of how to format a date in js here:

http://www.webdevelopersnotes.com/tips/html/10_ways_to_format_time_and_date_using_javascript.php3



来源:https://stackoverflow.com/questions/5931557/datepicker-onselect-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!