我经常发现这个话题,但我仍然无法解决问题。这是我在浏览器中查看的页面(它包括标题,通过php导航)。 $.datepicker.setDefaults
似乎工作正常,但$(function() { $( "#dateFrom" ).datepicker(); } );
会引发错误。我尝试使用文档就绪函数以及$.noconflict()
函数。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/header.css">
<link rel="stylesheet" href="css/navigation.css">
<link rel="stylesheet" href="css/footer.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$.datepicker.setDefaults({
dateFormat: 'dd.mm.y'
});
$.datepicker.setDefaults({
dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa']
});
$.datepicker.setDefaults({
monthNames: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]
});
$.datepicker.setDefaults({
inline: true
});
$.datepicker.setDefaults({
showOtherMonths: true
});
$.datepicker.setDefaults({
firstDay: 1
});
</script>
<title>[...]</title>
</head>
<body>
<div id="header">
<a href="index.php">
<span class="title">[...]</span>
<a href="[...]" class="logo" title="Startseite"><img src="./img/logo-son.png" alt="" /></a>
</a>
<div id="authenticatedUser">
<br /> Eingeloggt als: </div>
</div>
<div id="wrapper">
<div id="navigation">
<a href="index.php">
<div class="nav_eintrag">
Startseite
</div>
</a>
[...]
</div>
<script>
$(function() {
$("#dateFrom").datepicker();
});
</script>
<div id="content">
<h1>[...]</h1>
<form name="[...]" action="[...]" method="post">
[...]
<input type="text" class="searchInput" name="dateFrom" id="dateFrom" placeholder="Startdatum"> [...]
<input style="float:right" type="submit" name="action" value="Absenden">
</div>
</form>
<br>
<link rel="stylesheet" type="text/css" href="DataTables/datatables.css" />
<script type="text/javascript" src="DataTables/datatables.js"></script>
<div class="exportButtons">
<div class="inner"></div>
</div>
<table id="AssignmentTable">
<thead>
<tr class="header">
<th>Area ID</th>
[...]
</tr>
</thead>
<tbody>
<pre>Array
[...]
</pre> </tbody>
</table>
</div>
</div>
<script>
var table = $('#AssignmentTable').DataTable();
table.page.len(25).draw();
new $.fn.dataTable.Buttons(table, {
buttons: [{
extend: 'excelHtml5',
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row c', sheet).each(function() {
$(this).attr('s', '50');
});
}
}]
});
</script>
<div id="footer">
</div>
</body>
</html>
我缩短了页面,所以读取的垃圾更少。