首页 文章

日期选择器的jquery时间选择器插件

提问于
浏览
1

我正在尝试使用Time Picker插件(http://trentrichardson.com/examples/timepicker/)实现jQuery UI Date Picker .

我将js和css分别保存在与我的脚本相同的目录中,分别保存在timpicker.js和picker.css中 .

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Datepicker - Select a Date Range</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<link rel="stylesheet" href="picker.css" />
<script src="timepicker.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$('#from').datetimepicker();
</script>
</head>
<body>
<label for="from">From</label>
<input type="text" id="from" name="from" />
</body>
</html>

Firebug一直给我这些错误:

ReferenceError: jQuery is not defined
[Break On This Error]   

})(jQuery);

datetimepicker.js (line 1919)

TypeError: $(...).datetimepicker is not a function
[Break On This Error]   

$('#from').datetimepicker();

有没有其他人遇到过这个问题 . 我确定我错过了一些简单的东西,但我一直找不到有同样问题的人 .

谢谢

1 回答

  • 6

    您在加载jQuery之前加载timepicker.js . 您的页面正在尝试运行timepicker.js,并且对jQuery一无所知 . 重新排列脚本,如:

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

相关问题