JQuery官方的Datepicker控件,可以很方便的使用,可以让用户很方便的在输入框上选择时间。
废话少说,现在进入正题
一、国际惯例,先上实例
1、代码
<script
>
$ ( function ( ) {
$ ( "#datepicker" ) .datepicker ( ) ;
} ) ;
</script>
Date : <input id = "datepicker" type = "text" />
$ ( function ( ) {
$ ( "#datepicker" ) .datepicker ( ) ;
} ) ;
</script>
Date : <input id = "datepicker" type = "text" />
2、效果
本文已经同步至我的个人博客站点:
jquery ui(五)日期选择器 datepicker ( http://ifxoxo.com/jquery-ui-datepicker.html )
二、具体用法
1、需要加载文件
(1)jquery.js
(2)jquery.ui
(3)jquery.ui的css
<script type
=
"text/javascript" src
=
"http://code.jquery.com/jquery-1.9.1.js"
>
</script>
<script type = "text/javascript" src = "http://code.jquery.com/ui/1.10.3/jquery-ui.js" > </script>
< link href = "http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"
rel = "stylesheet" />
<script type = "text/javascript" src = "http://code.jquery.com/ui/1.10.3/jquery-ui.js" > </script>
< link href = "http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"
rel = "stylesheet" />
2、页面上的HTML代码
需要一个用来加载datepicker控件的输入框
<input id
=
"date" type
=
"text"
/>
3、js代码
最简单的初始化函数:
$
(
.selecter
)
.datepicker
(
)
4、datepicker()的参数
datepicker非常强大,所以也提供了很多使用的参数,先看一个复杂一点的例子,然后再介绍参数。