【问题标题】:How to hide HTML calendar after adding JQuery datepicker in Firefox?在 Firefox 中添加 JQuery datepicker 后如何隐藏 HTML 日历?
【发布时间】:2020-08-02 19:26:43
【问题描述】:

我的问题是第二个日历,它与 first.Only 在 Firefox 上同时显示。 我在代码中添加了 JQuery datepicker 以使日历在 IOS 上工作,现在在 IOS 上还可以,但在 Firefox 上,我从 Jquery 和基本 HTML 日历中获得了 input type="date" 的日历。

我想像在其他浏览器上一样删除 Firefox 中的 HTML 日历,只保留 JQuery 日历。

感谢您的帮助。

Image 1 Image 2

这是我的代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
    <link type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
</head>
<body>
    <input type="date" class="calendar-delivery">

<script type="text/javascript">
       $(window).on('load', function () {
            if ( $('.calendar-delivery')[0].type = 'date' )
            {
                $('.calendar-delivery').datepicker(
                {
                    dateFormat: "dd-mm-yy",
                    minDate: -5,
                    maxDate: +5,       
                    beforeShowDay: function(date) {
                    var day = date.getDay();
                    return [(day != 0), ''];
                    }
                }   
                );        
            }
         });
</script>
</body>
</html>

【问题讨论】:

    标签: jquery jquery-ui jquery-ui-datepicker


    【解决方案1】:

    问题是因为您在 date 输入上定义了选择器。它需要用于普通的text 输入。

    还要注意,在你的 JS 中检查字段类型的条件应该被删除。部分是因为上面的原因,也因为逻辑被打破了。 = 用于设置值,而===== 应用于检查相等性。

    $(window).on('load', function() {
      $('.calendar-delivery').datepicker({
        dateFormat: "dd-mm-yy",
        minDate: -5,
        maxDate: +5,
        beforeShowDay: function(date) {
          var day = date.getDay();
          return [(day != 0), ''];
        }
      });
    });
    <script src="https://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
    <link type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
    <input type="text" class="calendar-delivery">

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-12
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      • 1970-01-01
      相关资源
      最近更新 更多