只要对我在日期选择器中的工具提示有疑问。 如果我将工具提示添加到日期选择器,日历数字会向右移动。 我无法用 jsfiddle 重现错误,但以下是代码和图片。如果我看一下工具提示,它会生成 style="left:135.208px"?
html
<div id="datepicker99"></div>
JavaScript
var datesGreen = ['3/12/2015', '4/12/2015'];
var datesYellow = ['16/12/2015', '17/12/2015', '18/12/2015'];
var datesRed = ['24/12/2015', '25/12/2015'];
$("#datepicker99").datepicker({
format: "dd/mm/yyyy",
autoclose: true,
todayHighlight: true,
beforeShowDay: function(date){
var d = date;
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1; //Months are zero based
var curr_year = d.getFullYear();
var formattedDate = curr_date + "/" + curr_month + "/" + curr_year
if ($.inArray(formattedDate, datesGreen) != -1){
return {
tooltip: 'text',
classes: 'highlight-green'
};
}
if ($.inArray(formattedDate, datesYellow) != -1){
return {
classes: 'highlight-yellow'
};
}
if ($.inArray(formattedDate, datesRed) != -1){
return {
classes: 'highlight-red'
};
}
return;
}
});
$('.highlight-green').tooltip({placement : 'top'});
CSS
.ui-widget{
font-size: 0.7em;
}
td.highlight {
}
td.highlight-green {
background: green!important;
color: #fff!important;
}
td.highlight-yellow {
background: yellow!important;
color: #000!important;
}
td.highlight-red {
background: red!important;
color: #fff!important;
}
和 jsfiddle:
最佳答案
如果您应用以下更改,它工作正常:
$('.highlight-green').tooltip({placement : 'top', container: 'body'});
关于javascript - 日期选择器 Bootstrap 中的工具提示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34268805/