jquery datepicker 应用笔记

var fromdatefunction=function(){
	var maxdate=" -1d";
	if($('#todate').val())	{	maxdate=$('#todate').val();}
	$( "#fromdate" ).datepicker({ 
		changeMonth: true,
		changeYear:true,
		//dayNamesMin:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],
		//dayNamesMin: [ "Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa" ],
		firstDay: 1 ,//以星期1 作为一周的第一天
		gotoCurrent: true,
//		showButtonPanel: true,
		hideIfNoPrevNext: false,
		maxDate: maxdate,
		//maxDate: "+2m +1w",//最大时间 两个月 1周后
		minDate: new Date(2012, 1 - 1, 1),//最小时间
		//yearRange: "2008:2012",//显示从2002年到2012年,和maxDate 和 minDate 取交集
		//yearSuffix: "CE",//年的前缀,但是当年和月位置对调出现问题
		//dialog:"xxx",
		setDate:"+1m +7d",
		monthNames: ["01","02","03","04","05","06","07","08","09","10","11","12" ],
		monthNamesShort: ["01","02","03","04","05","06","07","08","09","10","11","12" ],
		showCurrentAtPos: 0,//默认展示当前月
		//showCurrentAtPos: -1,//默认展示一个月后
		nextText:"下一月",
		prevText:"前一月",
		numberOfMonths: [1,1],//展示1行1列
		showMonthAfterYear: true,//年在月前输出
		dateFormat: "yy-mm-dd"
//		showOtherMonths:false,
//		showOn: "both",
//		direction: "up",
//		stepMonths: 1, //上3 月,下三月
//		showWeek: true,//显示一年中的第几周
//		weekHeader: "W",
	});
}
var todatefunction=function(fromdatevalue){
	var mindate=new Date(2012, 1 - 1, 1);
	if($('#fromdate').val())	{	mindate=$('#fromdate').val();}
	$( "#todate" ).datepicker({ 
		changeMonth: true,
		changeYear:true,
		//dayNamesMin:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],
		//dayNamesMin: [ "Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa" ],
		firstDay: 1 ,//以星期1 作为一周的第一天
		gotoCurrent: true,
//		showButtonPanel: true,
		hideIfNoPrevNext: false,
		maxDate: "-1d",
		//maxDate: "+2m +1w",//最大时间 两个月 1周后
		minDate: mindate,//最小时间
		//yearRange: "2008:2012",//显示从2002年到2012年,和maxDate 和 minDate 取交集
		//yearSuffix: "CE",//年的前缀,但是当年和月位置对调出现问题
		//dialog:"xxx",
		setDate:"+1m +7d",
		monthNames: ["01","02","03","04","05","06","07","08","09","10","11","12" ],
		monthNamesShort: ["01","02","03","04","05","06","07","08","09","10","11","12" ],
		showCurrentAtPos: 0,//默认展示当前月
		//showCurrentAtPos: -1,//默认展示一个月后
		nextText:"下一月",
		prevText:"前一月",
		numberOfMonths: [1,1],//展示1行1列
		showMonthAfterYear: true,//年在月前输出
		dateFormat: "yy-mm-dd"
//		showOtherMonths:false,
//		showOn: "both",
//		direction: "up",
//		stepMonths: 1, //上3 月,下三月
//		showWeek: true,//显示一年中的第几周
//		weekHeader: "W",
	});
}
$(function() {
	fromdatefunction();
	todatefunction();
	$( "#todate" ).change(function(){
		 $( "#fromdate" ).datepicker( "destroy" );
		fromdatefunction();
	})
	$( "#fromdate" ).change(function(){
		 $( "#todate" ).datepicker( "destroy" );
		todatefunction();
	})
});

 备忘x

 

你可能感兴趣的:(JavaScript,js,jquery,Date,Datepicker)