添加jQuery Datepicker后下拉菜单不起作用

时间:2019-04-29 10:57:06

标签: php bootstrap-datepicker

添加日期选择器头文件和jQuery代码后,导航栏中的下拉菜单不起作用。

我的日期选择器头文件:

<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

导航栏的下拉菜单不起作用

<li class="nav-item dropdown d-none d-xl-inline-block">
    <a class="nav-link dropdown-toggle" id="UserDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
        <span class="profile-text pro">Hello, &nbsp;  <?php echo $username;?> </span>
    </a>
    <div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="UserDropdown">
        <a class="dropdown-item mt-2"  href='studentprofile.php?username=<?php  echo $username ?>'>
            View profile
        </a>
        <a class="dropdown-item" href='changepassword.php?username=<?php  echo $username ?>'>
            Change Password
        </a>
        <a class="dropdown-item" href="login.php">
            Sign Out
        </a>
    </div>
</li>

<script type="text/javascript">
// When the document is ready
$(document).ready(function () {    
    $('#from').datepicker({
        autoclose: true,  
        format: "dd/mm/yyyy"
    });  
    event.preventDefault();
});
</script>

1 个答案:

答案 0 :(得分:0)

尝试将您的JQuery更改为

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>