twitter-bootstrap 如何设置 bootstrap-datepicker
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19764560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to setup bootstrap-datepicker
提问by vlio20
I am trying to use the bootstrap-datepicker. The problem is that I am getting only the input filed without no styles. Here are my includes:
我正在尝试使用bootstrap-datepicker。问题是我只收到没有样式的输入文件。这是我的包括:
<link href="../css/bootstrap.css" rel="stylesheet" media="screen">
<link href="../css/datepicker.css" rel="stylesheet">
<link href="../css/main.css" rel="stylesheet">
<script src="../js/jquery.js"></script>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="../js/assets/html5shiv.js"></script>
<script src="../js/assets/respond.min.js"></script>
<![endif]-->
<script src="../js/bootstrap.min.js"></script>
<script src="../js/assets/bootstrap-datepicker.js"></script>
<script src="../js/main.js"></script>
here is the html:
这是html:
<div class="input-append date" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<input id="dp3" size="16" type="text" value="12-02-2012"/>
<span class="add-on"><i class="icon-calendar" id="cal2"></i></span>
</div>
and here is the javascript :
这是javascript:
$('#dp3').datepicker();
what is wrong??
怎么了??
Note:No when I focus into the input the calender appears but there is no icon.
注意:不,当我专注于输入时,日历会出现,但没有图标。
回答by totymedli
If you use this versionthan you have to use it with Bootstrap 2 because it doesn't fully support Bootstrap 3. If you use Bootstrap 3 you have to deal with the icon problemyourself, by adding a different icon, use a button instead or completely remove that part.
如果您使用此版本,则必须将其与 Bootstrap 2 一起使用,因为它不完全支持 Bootstrap 3。如果您使用 Bootstrap 3,则必须自己处理图标问题,通过添加不同的图标,使用按钮代替或完全移除那部分。
回答by Praveen
回答by Sridhar R
To solve this, either make this call when DOM is loaded:
要解决此问题,请在加载 DOM 时进行此调用:
$(function() {
$('#dp3').datepicker();
});
OR
或者
$(document).ready(function(){
$('#dp3').datepicker();
});

