jQuery datepicker maxDate auto onmouseover

时间:2016-03-03 06:28:14

标签: javascript jquery css jquery-ui datepicker

美好的一天,

我有一个日期选择器,我将选择限制设置为今天之前的5天。 这是我的示例代码:

$(function() {

    var from_date = $(':input[name="dailyCommand.fromDate"]');
    var endDate = new Date();
    endDate.setDate(endDate.getDate() - 5);

    from_date.prop('readonly',true).datepicker({maxDate: endDate});

})

例如,假设今天是2016年3月3日。 datepicker正在查找,但只是最后一天会自动对焦,这是我的屏幕截图: enter image description here

当我点击文本框时,图像1是日期选择器。从图片中可以看出,今天的第5天(2016年2月27日),显示的颜色如mouseover,但实际上没有,我没有将鼠标指向第27位,我只是点击了日期选择器文本框。

然而,在图像2中,我将鼠标移动到拾取器中的任何一天,第27种颜色将像其他颜色一样显示,因为“鼠标悬停”颜色已经在其他日期。然后我将鼠标从日期选择器上移开,整个事情现在正确显示。

我的问题是当我第一次点击日期选择器文本框时,如何将第27种颜色修复为与颜色相同。

当我尝试在w3c网站上模拟时,同样的事情发生了,第27次看起来像onmouseover

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
</head>
<body>
<script type="text/javascript">
$(function() {
    var from_date = $(':input[name="dafromDate"]');
    var endDate = new Date();
    endDate.setDate(endDate.getDate() - 5);

    from_date.prop('readonly',true).datepicker({maxDate: endDate});

})
</script>

<input type="text" name="dafromDate" maxlength="20"/>
<p><b>Note:</b> type="date" is not supported in Internet Explorer.</p>

</body>
</html>

0 个答案:

没有答案