【发布时间】:2014-04-07 08:49:34
【问题描述】:
我正在使用JQuery 实现日历。这是我测试的 pure html 表单,它运行良好。但是当我将它嵌入到 php 中时,它不起作用并且当我选择检查元素时出现错误是--> 对象没有方法 datepicker。
纯 HTML:
<html lang="en">
<head>
<title>Date Thing</title>
<link href="jquery-ui-1.10.4.custom/css/start/jquery-ui-1.10.4.custom.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.js"></script>
<script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$( "#datepickerID" ).datepicker({
changeYear: true,
})
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepickerID"></p>
</body>
</html>
PHP 代码:
<?php
include('sess.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>PAGE TITLE</title>
<link rel="stylesheet" type="text/css" href="bootstrap.css">
<link rel="stylesheet" type="text/css" href="bootstrap.theme.css">
<link href="jquery-ui-1.10.4.custom/css/start/jquery-ui-1.10.4.custom.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.js"></script>
<script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$( "#datepickerID" ).datepicker({
changeYear: true,
})
});
</script>
</head>
<body>
<form name="form1" action="http://*****/******/redirect1.php" onsubmit="return validateForm();" method="get">
<p>Date: <input type="text" id="datepickerID"></p>
</form>
</body>
</html>
有人可以告诉我如何使该日历即使在 php 代码中也能正常工作?
【问题讨论】:
-
确保js文件没有在整个代码中重复,可能有js代码冲突,你在错误控制台中遇到什么样的错误?
-
控制台中的任何其他错误。
-
@SagarPanchal 同样的错误--> 对象没有日期选择器方法。如果您可以提供工作示例,请使用 php。
-
@Jai 没有其他错误。除了这个。
-
@rick 检查我的答案