JQuery Datepicker

1、下载JQuery

http://jquery.com/

http://jqueryui.com/

 

2、HTML页面

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JQuery Datepicker</title>
<link type="text/css" href="script/jquery/theme/base/jquery-ui.css" rel="stylesheet" />
<link type="text/css" href="script/jquery/theme/base/jquery.ui.core.css" rel="stylesheet" />
<link type="text/css" href="script/jquery/theme/base/jquery.ui.theme.css" rel="stylesheet" />
<link type="text/css" href="script/jquery/theme/base/jquery.ui.accordion.css" rel="stylesheet" />
<script type="text/javascript" src="script/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="script/jquery/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="script/jquery/ui/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="script/jquery/ui/i18n/jquery.ui.datepicker-ja.js"></script>
<script type="text/javascript">
$(document).ready(function(){  
	var date=new Date();  
	var day=date.getDate();  
	day=parseInt(day)-1;  
	date=new Date(parseInt(date.getFullYear()),parseInt(date.getMonth())+1,0);  
	$("#datepicker").datepicker({
		showOn:'button',
		buttonImage:'image/calendar.gif',
		buttonImageOnly:true,
		minDate:-day,
		maxDate:+parseInt(date.getDate())-day-1
	});  
});  
function initAnother(){  
	if(document.getElementById("datepicker").value!=null){  
  		$("#another").datepicker({minDate:'-3d'});
 	}  
}  
function initCalendar(){  
	if(document.getElementById("datepicker").value!=null){  
  		$("#another").datepicker({minDate:'-3d'});  
	}  
}  
</script>
<style type="text/css">
.demo input,img{
	vertical-align:middle;
}
</style>
</head>
<body>
	<div class="demo">
		date: <input type="text" id="datepicker" onchange="initAnother()">
		<br/><br/>
		date: <input type="text" id="another" onfocus="initCalendar()">
	</div>
</body>
</html>

你可能感兴趣的:(JavaScript,html,jquery,UI,css)