我想知道如何在嵌入日历时将所选日期与bootstrap-datepicker放入输入字段。不知怎的,我无法让它发挥作用。
现在我有这个:
<script>
$('#sandbox-container div').datepicker({
weekStart: 1,
startDate: "-",
maxViewMode: 0,
clearBtn: true,
language: "nl",
orientation: "top auto",
daysOfWeekDisabled: "0,1,2,3,4",
calendarWeeks: true,
todayHighlight: true
});
</script>
在模板中我有:
<div id="sandbox-container">
<div id="datepicker"></div>
</div>
然而,当我尝试做类似的事情时:
<script>
$('#sandbox-container input').datepicker({
weekStart: 1,
startDate: "-",
maxViewMode: 0,
clearBtn: true,
language: "nl",
orientation: "top auto",
daysOfWeekDisabled: "0,1,2,3,4",
calendarWeeks: true,
todayHighlight: true
});
</script>
和
<div id="sandbox-container">
<input type=text id="datepicker">
</div>
它只显示一个输入字段。我做错了什么?
答案 0 :(得分:0)
两件事:
1)据推测,你知道datepicker附带了JQueryUI。但是,如果您不知道这一点,那么您首先需要在JQuery下包含它。例如:
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
2)其次,看起来您的选择器编写不正确。这应该有效:
<script>
$(function() {
$("#sandbox-container input").datepicker({
weekStart: 1,
startDate: "-",
maxViewMode: 0,
clearBtn: true,
language: "nl",
orientation: "top auto",
daysOfWeekDisabled: "0,1,2,3,4",
calendarWeeks: true,
todayHighlight: true
});
});
</script>