javascript 类型错误:$(...).timepicker 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31752772/
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
TypeError: $(...).timepicker is not a function
提问by Kamran
I am getting problem with Jquery timepicker(); function
Here it is
我在使用 Jquery timepicker() 时遇到问题;功能在这里
<link href="js/jqueryTimepicker/jquery.timepicker.css" rel="stylesheet" />
<script src="js/jquery-1.11.2.js"></script>
<script src="js/jqueryTimepicker/jquery-ui.js"></script>
<script src="js/jqueryTimepicker/jquery.timepicker.js"></script>
<script src="js/jqueryTimepicker/jquery.timepicker.min.js"></script>
This is HTML markup
这是HTML 标记
<div id="tableTime">
<table>
<tr>
<td>Monday</td>
<td>Tuesday</td>
<td>Wednesday</td>
<td>Thursday</td>
<td>Friday</td>
<td>Saturday</td>
</tr>
<tr>
<td>
<input type="text" id="txtMonday" /></td>
<td>
<input type="text" id="txtTuesday" /></td>
<td>
<input type="text" id="txtWednesday" /></td>
<td>
<input type="text" id="txtThursday" /></td>
<td>
<input type="text" id="txtFriday" /></td>
<td>
<input type="text" id="txtSaturday" /></td>
</tr>
</table>
</div>
JqueryAll of the above jquery files are loading well enough but it throws one error TypeError: $(...).timepicker is not a function Help!!! I am no where
Jquery上述所有jquery文件都加载得很好,但它抛出一个错误 TypeError: $(...).timepicker is not a function 求助!!!我无处可去
<script>
$(document).ready(function () {
$("#txtMonday").timepicker();
$("#txtTuesday").timepicker();
$("#txtWednesday").timepicker();
$("#txtThursday").timepicker();
$("#txtFriday").timepicker();
$("#txtSaturday").timepicker();
});
</script>
回答by rohit
One of your imports may not be working correctly since I got it working in a JSFiddle. Try redownloading the CSS/JS files and make sure they are in the correct locations. If that still doesn't work, you can use the CDNfor referencing the CSS/JS files.
您的其中一个导入可能无法正常工作,因为我在JSFiddle中使用了它。尝试重新下载 CSS/JS 文件并确保它们位于正确的位置。如果这仍然不起作用,您可以使用CDN来引用 CSS/JS 文件。
Put the following in your HTML code and it should be fixed
将以下内容放入您的 HTML 代码中,它应该被修复
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.1/jquery.timepicker.min.css"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.1/jquery.timepicker.min.js"></script>
Also, in future, I might suggest using a CSS class instead of individual id's like so:
此外,将来,我可能会建议使用 CSS 类而不是像这样的个人 ID :
$(document).ready(function () {
$('.txt').timepicker();
});
回答by Split
You may have a problem importing the files. Look: JSFiddle
您可能在导入文件时遇到问题。看:JSFiddle
Check the external resources that I used.
检查我使用的外部资源。
$(document).ready(function () {
$("#txtMonday").timepicker();
$("#txtTuesday").timepicker();
$("#txtWednesday").timepicker();
$("#txtThursday").timepicker();
$("#txtFriday").timepicker();
$("#txtSaturday").timepicker();
});
回答by Siddharth Shukla
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
<!-- Updated stylesheet url -->
<link rel="stylesheet" href="//jonthornton.github.io/jquery-timepicker/jquery.timepicker.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
<!-- Updated JavaScript url -->
<script src="//jonthornton.github.io/jquery-timepicker/jquery.timepicker.js"></script>
<script>
$(function() {
$("#datepicker").datepicker();
});
$(function() {
$('#timepicker1').timepicker();
});
$(function() {
$("#datepicker1").datepicker();
});
$(function() {
$('#timepicker2').timepicker();
});
</script>
</head>
<body style="background-color:#E8E9E9;">
<form method="post" action="makecleaningappt">
<input type="text" id="datepicker" name="date">
<br>
<input type="text" id="timepicker1" name="time">
<input type="text" id="datepicker1" name="date">
<br>
<input type="text" id="timepicker2" name="time">
</form>
</body>
</html>