Datepicker onSelect不起作用 [英] Datepicker onSelect not working

查看:532
本文介绍了Datepicker onSelect不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面的功能似乎无法正常运行,请提供一些帮助.该功能基本上为使用日期选择器选择的日期增加了30天.

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)
   }
});

我看不到我要去哪里.选择日期后,它会在地址栏URL上添加一个空白锚(如果有帮助的话).

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.

谢谢.

推荐答案

问题是date.format('mm/dd/yyy')正在爆炸.

有关如何在js中格式化日期的示例:

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

这篇关于Datepicker onSelect不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆