使用哪些图书馆来显示日期采访工具?

时间:2014-10-10 07:09:22

标签: jquery datepicker

我想在输入元素获得焦点时显示一个datepicker弹出窗口:

    $(document).ready(function(){
        $(".datepicker").on('click',function(){
            $(this).datepicker({
                buttonImageOnly: true,
                changeMonth: true,
                changeYear: true,
                showWeek: true,
                firstDay: 1
            });
            $(this).datepicker('show');
        });
    });

为了使此代码有效,需要哪些js个文件?

3 个答案:

答案 0 :(得分:1)

<script src="Scripts/jquery-ui-1.10.4.js"></script>
<link href="Content/jquery-ui-1.10.4.css" rel="stylesheet" />

答案 1 :(得分:1)

Datepicker是jquery UI的一部分,这是一个例子:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>

答案 2 :(得分:1)

您需要jQuery UI库,您只需使用:

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
    $(".datepicker").datepicker({
        buttonImageOnly: true,
        changeMonth: true,
        changeYear: true,
        showWeek: true,
        firstDay: 1
    });
});
</script>