javascript JQuery UI - 无法让日期选择器工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19344977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQuery UI - Can't get datepicker to work
提问by user568021
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:
问题很简单。我已正确包含所有内容,但日期选择器不会出现。我在我的 html head 标签中添加了脚本:
<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... :(
就是这样。该文本输入上没有日期选择器或任何内容。也没有错误... :(
回答by Jason W
include jquery before jquery ui.
在 jquery ui 之前包含 jquery。
<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:
日期: