我有两种形式,我将其命名为 main.php 和 sample.php....对于主要.php我有一个日历/日期选择器及其工作。但是当我进入下一页或示例时.php日历/日期选择器不再显示......我只是将代码从 main.php 复制到样本.php
这是我的 main.php 代码:
<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>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#datepickerfrom" ).datepicker();
});
$(function() {
$( "#datepickerto" ).datepicker();
});
</script>
From: <input type="text" id="datepickerfrom"name="from"> To: <input type="text" id="datepickerto"name="to">
对于示例.php:
<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>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function () {
$('.checkall').on('click', function () {
$(this).closest('fieldset').find(':checkbox').prop('checked', this.checked);
});
});
$(function() {
$( "#datepickerfrom" ).datepicker();
});
$(function() {
$( "#datepickerto" ).datepicker();
});
</script>
From: <input type="text" id="datepickerfrom"name="from"> To: <input type="text" id="datepickerto"name="to">
<?php
echo "<div><input type='checkbox' class='checkall'> Check all</div>";
?>
但是在示例中.php我添加了复选框的代码,其中我还使用脚本...
谢谢/。
那是因为您在sample.php
中调用了两次jquery
。任一删除
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
或
<script src="http://code.jquery.com/jquery-latest.js"></script>
附言jquery-ui.js
应该在jquery
之后
<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>
您需要样本.php上的这些行,尝试过,它奏效了。