日期时间选择器不工作.引导.Laravel

datetimepicker not working. Bootstrap. Laravel

本文关键字:引导 Laravel 工作 时间 选择器 日期      更新时间:2023-09-26

我的日期时间选择器不能正常工作。我不知道怎么了。我使用了以下语法:布局:

<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
    <meta charset="utf-8"/>
    <title>@yield('title')</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <link rel="stylesheet" href="{{ asset("assets/stylesheets/styles.css") }}" />
</head>
<body>
    @yield('body')
    <script src="{{ asset("assets/scripts/frontend.js") }}" type="text/javascript"></script>
</body>
</html>

视图:

 <div class="form-group">
                <label>Date of Birth</label>
                <div class='input-group date' id='dob' >
                    <input type='text' class="form-control" name="dob"/>
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        <script type="text/javascript">
            $(function () {
                $('#dob').datetimepicker();
            });
        </script>

当我尝试点击日期图标。它只是变成了文本编辑器符号。我不能点击图标。这里的问题是什么?有人能帮我吗?

您需要为图标日历创建自定义单击事件。

为文本字段分配作业ID。

试试这个:

$(function() {
  $('#dob').datetimepicker();
});
$(".glyphicon-calendar").click(function() {
  $("#dob").datepicker("show");
});
<div class="form-group">
  <label>Date of Birth</label>
  <div class='input-group date'>
    <input type='text' class="form-control" name="dob" id='dob' />
    <span class="input-group-addon">
<span class="glyphicon glyphicon-calendar">
      </span>
    </span>
  </div>
</div>