Bootstrap datepicker默认日期 [英] Bootstrap datepicker default date

查看:1037
本文介绍了Bootstrap datepicker默认日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Bootstrap datepicker,我想在datepicker显示时默认日期将在今天14天后设置。我有这个代码,但它不起作用,默认日期仍然设置为今天。有没有人可以解释我失踪了什么?提前致谢。

I'm using Bootstrap datepicker and I'd like to make that when datepicker shows, default date would be set after 14 days from today. I've got this code but it doesn't work, default date is still set to today. Could anyone explain what am I missing? Thanks in advance.

JS:

  var plus14days = new Date();

  plus14days.setDate(plus14days.getDate() + 14 );
  $(".datepicker").datepicker("setValue", plus14days);


推荐答案

你使用的代码是对的。

The code you've used is right.

日期将显示在文本框中,但不在日期戳记日历

The date will be displayed in textbox, but not in datepicker calendar like this

要启用此功能,您需要使用以下代码更新它:

To enable this feature you need to update it using the following code:

$(".datepicker").datepicker('update');

现在看起来像

JSFiddle

这篇关于Bootstrap datepicker默认日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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