admin管理员组文章数量:1419226
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">
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">
Share
Improve this question
edited Apr 18, 2022 at 15:39
TylerH
21.1k79 gold badges79 silver badges114 bronze badges
asked Mar 31, 2017 at 15:17
IsraelIsrael
211 silver badge2 bronze badges
4
- Did you try Jquery's prevent.default ? – oneNiceFriend Commented Mar 31, 2017 at 15:21
-
In chrome you can access using
input::-webkit-calendar-picker-indicator
, I do not know if you can trigger click for that element$('input::-webkit-calendar-picker-indicator').click()
Just in case take a look at this question stackoverflow./questions/14946091/… – Miguel Lattuada Commented Mar 31, 2017 at 15:32 - I've tried $('input::-webkit-calendar-picker-indicator').click() and $('#elementid::-webkit-calendar-picker-indicator').click() but it didn't worked. – Israel Commented Mar 31, 2017 at 15:49
- How should I use prevent.default in this case? I've not understood where to use it and how the calendar would be shown doing this. – Israel Commented Mar 31, 2017 at 15:51
1 Answer
Reset to default 6I 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;
}
本文标签: javascriptIs there a way to trigger a date input39s calendar on double clickStack Overflow
版权声明:本文标题:javascript - Is there a way to trigger a date input's calendar on double click? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745302113a2652430.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论