jquery的datepicker

10 篇文章 0 订阅
更详细介绍官网:http://jqueryui.com/demos/datepicker/



第一次使用jquery的datepicker时,找了很久才找到怎么设置中文,今天重新学习了一下,原来jquery已经自带好了,在jquery根目录/development-bundle/ui/i18n/每个国家相对于的语言js文件,简体中文的为jquery.ui.datepicker-zh-CN.js。




<link href="jquery/css/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript" src="jquery/js/jquery-1.6.2.min.js"></script>

<script type="text/javascript" src="jquery/js/jquery-ui-1.8.16.custom.min.js"></script>

<script type="text/javascript" src="jquery/jquery.ui.datepicker.js"></script>

<script type="text/javascript" src="jquery/jquery.ui.datepicker-zh-CN.js"></script>//包含它后就会显示中文


<script>

$(function(){

$("#datapicker").datepicker({

disabled:false,

altField:'#alt',//与改日期相关联的日期

altFormat:'y-m-d',//相关联日期的格式

appendText:'(yyyy-mm-dd)',//

autoSize:true,

changeMonth:true,

changeYear:true,

dateFormat:'yy/mm/dd',//初始化时的日期格式

duration: 'fast',//这个日期插件显示的速度{'slow','normal','fast'}

showButtonPanel: true ,//增加‘今天’、‘关闭’按钮在底部

showOn: 'button',//展示方式,‘focus’,‘button’,'both',默认为focus

});

})

</script>

</head>

<body style="font-size:62.5%;">

<input type="text" id="datapicker">

<input type="text" id="alt">

</body>



获取datepicker的任意option的值:$("#datapicker").datepicker('option','name');//name为option的名字,如'dateFormat';

设置datepicker的某个属性的值:$("#datapicker").datepicker('option','name','value');



功能函数:

1 $.datepicker.setDefaults();//设置所有的datepicker插件的默认属性,当一个页面中有多个datepicker插件时可以通过该函数设置所有插件都有的属性。例如:

$.datepicker.setDefaults(

{ showOn:'both',

buttonText:'日期',

}

$.datepicker.setDefaults($.datepicker.regional['zh']);//设置所有的日期插件显示为中文

2 $.datepicker.formatDate(format,date,settings).设置日期格式
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值