JQuery UI - Can't get datepicker to work [duplicate]

一个人想着一个人 提交于 2019-12-18 09:16:34

问题


The question is very simple. I have everything included properly, but the datepicker just won't show up. I have the script added in my html head tag:

<script type="text/javascript" src="<?php echo site_url('js/jquery-1.10.2.min.js'); ?>"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>
<link rel="stylesheet" href="<?php echo site_url('css/jquery.ui.core.css'); ?>">
<link rel="stylesheet" href="<?php echo site_url('css/jquery.ui.datepicker.css'); ?>">

Than the date picker code...

<input type="text" name="date" id="date">
<script type="text/javascript">
    $(document).ready(function() {
        $( "#date" ).datepicker({ dateFormat: "yy-m-d" });  
    });
</script>

And that's it. There's no date picker or anything on that text input. Also no error... :(


回答1:


include jquery before jquery ui.

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

working code

  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
   $( "#date" ).datepicker();
 });
</script>

Date:



来源:https://stackoverflow.com/questions/19344977/jquery-ui-cant-get-datepicker-to-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!