关闭

jquery-ui 插件学习--日期控件datepicker

标签: stylesheetfunctionclassbuttondivinput
1740人阅读 评论(2) 收藏 举报
分类:
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>jQuery UI Datepicker - Format date</title>
	<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
	<script src="../../jquery-1.7.1.js"></script>
	<script src="../../ui/jquery.ui.core.js"></script>
	<script src="../../ui/jquery.ui.widget.js"></script>
	<script src="../../ui/jquery.ui.datepicker.js"></script>
	<link rel="stylesheet" href="../demos.css">
	<script>
	$(function() {

		$( "#datepicker" ).datepicker();
		
		$( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val());

		$( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd');


	});
	</script>
</head>
<body>
 
<div class="demo">
 
<p>Date: <input type="text" id="datepicker" size="30"/></p>
 
<p>Format options:<br />
	<select id="format">
		<option value="mm/dd/yy">Default - mm/dd/yy</option>
		<option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>
		<option value="d M, y">Short - d M, y</option>
		<option value="d MM, y">Medium - d MM, y</option>
		<option value="DD, d MM, yy">Full - DD, d MM, yy</option>
		<option value="'day' d 'of' MM 'in the year' yy">With text - 'day' d 'of' MM 'in the year' yy</option>
	</select>
</p>
 
</div><!-- End demo -->
 
 
 
<div class="demo-description">
<p>jquery-ui默认的日期格式一般不是我们要的,要展现正确的格式,这个插件才有实际用途。这个例子使用下拉框的值区设定日期控件的值,我们在实际中使用可以把这个参数写死。<br>
	$(function() {

		$( "#datepicker" ).datepicker();
		
		$( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val());

		$( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd');


	}); </p>这样的格式显示为:2012-03-16
</div><!-- End demo-description -->
 
</body>
</html>


 

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>jQuery UI Datepicker - Icon trigger</title>
	<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
	<script src="../../jquery-1.7.1.js"></script>
	<script src="../../ui/jquery.ui.core.js"></script>
	<script src="../../ui/jquery.ui.widget.js"></script>
	<script src="../../ui/jquery.ui.datepicker.js"></script>
	<link rel="stylesheet" href="../demos.css">
	<script>
	$(function() {

		$( "#datepicker" ).datepicker({
			showOn: "button",
			buttonImage: "images/calendar.gif",
			buttonImageOnly: true
		});

		$( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd');

	});
	</script>
</head>
<body>
 
<div class="demo">
 
<p>Date: <input type="text" id="datepicker"></p>
 
</div><!-- End demo -->
 
 
 
<div class="demo-description">
<p>这个样子是我们比较喜欢和常用的,点击右边的按钮弹出控件。</p>
	$(function() {

		$( "#datepicker" ).datepicker({
			showOn: "button",
			buttonImage: "images/calendar.gif",
			buttonImageOnly: true
		});

		$( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd');

	});
</div><!-- End demo-description -->
 
</body>
</html>


 

 

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1307622次
    • 积分:14633
    • 等级:
    • 排名:第797名
    • 原创:320篇
    • 转载:247篇
    • 译文:0篇
    • 评论:98条