Bootstrap 日期选择器 - “todayHighlight:true"不工作 [英] Bootstrap Date picker - "todayHighlight:true" not working

查看:53
本文介绍了Bootstrap 日期选择器 - “todayHighlight:true"不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用引导程序 - 日期选择器(js 和 css).

以下是代码,无法找出错误.显示日期组件,但不会执行脚本中编写的任何规则.下面列出了一些.

format: "dd/mm/yyyy",开始日期:-7,结束日期:+3,今日亮点:真实

完整代码:

<div id="sandbox-container" class="input-group date" data-provide="datepicker"><input type="text" class="form-control"><div class="input-group-addon"><span class="glyphicon glyphicon-th"></span>

解决方案

使用 html 数据属性 或从 datepicker javascript 属性添加它.不要混淆两者.

小提琴:http://jsfiddle.net/hous9y5L/246/强>

您忘记了 startDateendDate

的双引号

HTML:

<input type="text" class="form-control"><div class="input-group-addon"><span class="glyphicon glyphicon-th"></span>

Javascript

$('#sandbox-container.input-group.date').datepicker({今日亮点:真实,格式:日/月/年",开始日期:-7d",结束日期:+3d"});

或者你可以这样做:

小提琴:http://jsfiddle.net/hous9y5L/248/

<div id="sandbox-container" class="input-group date" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-start-date="-7d" data-date-end-date="+3d" data-date-today-highlight="true"><input type="text" class="form-control"><div class="input-group-addon"><span class="glyphicon glyphicon-th"></span>

I am using bootstrap - date picker (js and css).

Following is the code, unable to figure out the error. Date component gets displayed but any rules that are written inside the script is not getting executed. some listed below.

format: "dd/mm/yyyy",
startDate: -7,
endDate: +3,
todayHighlight: true

FULL CODE:

<script>
$('#sandbox-container.input-group.date').datepicker({
todayHighlight: true
});
</script>

<div id="sandbox-container" class="input-group date" data-provide="datepicker">
<input type="text" class="form-control ">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
</div>

解决方案

Use html data attributes or add it from datepicker javascript properties. Don't mixup both.

Fiddle: http://jsfiddle.net/hous9y5L/246/

You forgot the double quotes for startDate and endDate

HTML:

<div id="sandbox-container" class="input-group date">
  <input type="text" class="form-control ">
  <div class="input-group-addon">
    <span class="glyphicon glyphicon-th"></span>
  </div>
</div>

Javascript

$('#sandbox-container.input-group.date').datepicker({
    todayHighlight: true,
    format: "dd/mm/yyyy",
    startDate: "-7d",
    endDate: "+3d"
});

or you can do this way:

Fiddle : http://jsfiddle.net/hous9y5L/248/

<div id="sandbox-container" class="input-group date" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-start-date="-7d" data-date-end-date="+3d" data-date-today-highlight="true">
  <input type="text" class="form-control ">
  <div class="input-group-addon">
    <span class="glyphicon glyphicon-th"></span>
  </div>
</div>

这篇关于Bootstrap 日期选择器 - “todayHighlight:true"不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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