Tôi có một số yếu tố đầu vào với loại = "ngày" và muốn tắt bộ chọn ngày mặc định trong Microsoft Edge vì tôi đang sử dụng công cụ datepicker của jQuery. Làm cách nào để tắt tính năng này bằng CSS hoặc JavaScript? Nó hoạt động tốt trong Chrome và Firefox chứ không phải Edge. Mọi câu trả lời sẽ được trân trọng.Làm thế nào để bạn vô hiệu hóa datepicker trong Microsoft Edge?
Một làm việc 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;
}
Chỉ cần một câu hỏi, tại sao bạn sử dụng cả hai loại 'date =" date "' và jQuery datepicker? Không phải là mục đích date date jqs od để thay thế 'type =" date "'? – Vucko
Vâng, tôi đang sử dụng 'type =" date "' để các trình chọn ngày của hệ thống hoạt động trên các thiết bị di động. Tôi đang sử dụng datepicker của jQuery cho máy tính để bàn và máy tính xách tay. –
Nhưng 'type =" date "' có [bas support] (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) ([caniuse] (http: // caniuse. com/# feat = input-datetime)), ngay cả đối với thiết bị di động. Tôi khuyên bạn nên sử dụng datepicker của jQ cho tất cả các thiết bị. – Vucko