我有几个输入type =“date”,并且想要禁用Microsoft Edge中的默认日期选择器,因为我使用的是jQuery的datepicker。如何使用CSS或JavaScript禁用此功能?它在Chrome和Firefox中运行良好,但不是Edge。任何答案将不胜感激。如何禁用Microsoft Edge中的日期选择器?
的工作jsFiddle
HTML
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
<input type="date">
JS
$(document).ready(function() {
if (!Modernizr.inputtypes.date || $(window).width() >= 900) {
$('input[type=date]').datepicker();
}
});
$(window).resize(function() {
if (!Modernizr.inputtypes.date || $(window).width() >= 900) {
$('input[type=date]').datepicker();
}
else {
$('input[type=date]').datepicker("destroy");
}
});
CSS
input[type=date]::-webkit-inner-spin-button, input[type=date]::-webkit-calendar-picker-indicator {
display: none;
-webkit-appearance: none;
}
只是一个问题,为什么你同时使用'type =“date”'和jQuerys datepicker?是不是用jQs datepicker替换'type =“date”'? – Vucko
那么,我使用'type =“date”',以便系统日期选择器在移动设备上工作。我只使用jQuery的datepicker作为桌面和笔记本电脑。 –
但是'type =“date”'[bas support](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input)([caniuse](http:// caniuse。 com /#feat = input-datetime)),即使是移动设备。我建议你为所有设备使用jQ的日期选择器。 – Vucko