'Is there a way to trigger a date input's calendar on double click?
I am trying to trigger the <input type="date">
calendar to be shown on a double click event, like a user was clicking on the arrow in the right, but with no success, because I could not identify how the browser implements it. (Chrome 56.0.2924.87).
Anyone have an idea if it's possible, and if so how I can do this?
<input type="date">
Solution 1:[1]
I found a better way that works across browsers.
The only negative is you don't get to see the icon.
The idea is to set the date input as relative and then absolutely position the datepicker icon to span the entire input, and set its opacity to 0 so it's not visible.
This triggers the datepicker across browsers when you click the input.
Code:
/* date styles */
.datepicker {
position: relative;
cursor: pointer;
box-sizing: border-box;
line-height: normal !important;
}
.datepicker::-webkit-calendar-picker-indicator {
position: absolute;
right: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
opacity: 0;
cursor: pointer;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |