Jquery控制My97DatePicker控件的日期格式

原文地址:http://blog.csdn.net/jimmy609/article/details/7569785


最近的项目,要取时间段进行统计,按照年月日时等方法,取按年统计的时候,我们希望时间控件只能选择年,按照月统计时候,我们希望只能选择年月这两项,因此写了这个小程序。

firefox测试可用。
<html>
	<head>
		<title>
			测试jquery控制My97DatetimePicker格式
		</title>
		<script type="text/javascript" src="WdatePicker.js"></script>
		<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
	</head>
	<body>
	<script type="text/javascript" >
	$(document).ready(function(){
    $('.time').bind('focus',function(){WdatePicker()});
	});
	function changeAttr1(){
		$('#start').unbind('focus');
		$('#start').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy'});});
		$('#end').unbind('focus');
		$('#end').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy',minDate:'#F{$dp.$D(\'start\')}'});});
	}
	function changeAttr2(){
	$('#start').unbind('focus');
		$('#start').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy年MM月'});});
	$('#end').unbind('focus')
		$('#end').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy年MM月',minDate:'#F{$dp.$D(\'start\')}'});});
	}
	function changeAttr3(){
	$('#start').unbind('focus');
		$('#start').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy年M月d日'});});
	$('#end').unbind('focus');
		$('#end').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy年M月d日',minDate:'#F{$dp.$D(\'start\')}'});});
	}
	function changeAttr4(){
	$('#start').unbind('focus');
		$('#start').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy年M月d日 HH时'});});
	$('#end').unbind('focus');
		$('#end').bind('focus',function(){WdatePicker({skin:'whyGreen',dateFmt:'yyyy年M月d日 HH时',minDate:'#F{$dp.$D(\'start\')}'});});
	}

	</script>
	<input id="start" class="time" type="text"/>
	<input id="end" class="time" type="text"/>
	<input id="1" type="button" value="变为年" οnclick="changeAttr1()">
	<input id="2" type="button" value="变为月" οnclick="changeAttr2()">
	<input id="3" type="button" value="变为日" οnclick="changeAttr3()">
	<input id="4" type="button" value="变为时" οnclick="changeAttr4()">
	</body>
</html>


效果图:






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值