【问题标题】:Bootstrap datepicker not showing even with function即使有功能,引导日期选择器也不显示
【发布时间】:2018-10-03 07:39:59
【问题描述】:

我在 js fiddle https://jsfiddle.net/9n3c8726/ 上有我的代码。单击该字段后,日期选择器需要立即显示。如您所见,我已经将它封装在一个函数中。任何帮助将不胜感激

Javascript

<script>
  $(function(){
    $('.datepicker').datepicker();
  });
</script>

HTML

<input class="datepicker" placeholder="Birthday" type="text" name="date">

【问题讨论】:

  • 你加载了太多的 jQuery 并且没有足够的日期选择器。请单击edit,然后使用[&lt;&gt;] 图标创建一个sn-p,并在此处使用相关 JS 和HTML 发布minimal reproducible example - 在控制台中查找也有错误
  • datepicker lib 不包含在 head 中...只需添加 cdn from : bootstrap-datepicker.readthedocs.io/en/latest
  • 阅读console 错误很重要。我在很多情况下,它说明出了什么问题:Uncaught TypeError: $(...).datepicker is not a function.

标签: javascript html twitter-bootstrap datepicker


【解决方案1】:

            <input class="datepicker" placeholder="Birthday" type="date" >
            

【讨论】:

    【解决方案2】:

    您需要包含一个日期选择器库。 Bootstrap 没有预先捆绑一个。看看类似https://eonasdan.github.io/bootstrap-datetimepicker/

    【讨论】:

      猜你喜欢
      • 2019-10-08
      • 1970-01-01
      • 1970-01-01
      • 2013-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多