jQuery datepicker 需要长按才能在 iPhone 中打开
<p><p>如何在 iPhone 中一键打开日期选择器?</p>
<p>在桌面和 Android 上都很好;只有在 iPhone 中我才需要长按或点击多次。</p>
<p>这是我的脚本:</p>
<pre><code>jQuery(".calendar-pick").datepicker({dateFormat: 'dd M, yy',minDate: 0});
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p></p><div class="snippet"data-lang="js"data-hide="false"data-console="true"data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var pressTimer;
//put below click if resolution is IPHONE long press on anchor link or textbox it will open after 2 secs
$(".calendar-pick, a").mouseup(function(){
clearTimeout(pressTimer);
// Clear timeout
return false;
}).mousedown(function(){
// Set timeout
pressTimer = window.setTimeout(function() {
//your code goes here first
$(".calendar-pick").datepicker("destroy");
$(".calendar-pick").datepicker({dateFormat: 'dd M, yy',minDate: 0});
$(".calendar-pick").focus();
},2000);
return false;
});
$(function(){
$(".calendar-pick").datepicker({dateFormat: 'dd M, yy',minDate: 0});
})</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<a href="#" >Hello</a>
<inputclass="calendar-pick" type="text" /></code></pre>
<p style="font-size: 20px;">关于jQuery datepicker 需要长按才能在 iPhone 中打开,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41950667/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41950667/
</a>
</p>
页:
[1]