<script> <br>function getTime(year,month,day){ <br>y = year <br>m = month <br>d = day <br>var myDate = new Date(year,month-1,day); <br>return myDate; <br>} <br>function days_in_month(year, month) { <br>y = year; <br>m = month; <br>return 32 - new Date(y, m - 1, 32).getDate(); <br>} <br>function view(year,month){ <br><br>var w = getTime(year,month,1).getDay()-1; <br>var num = days_in_month(year,month); <br>var index = 1; <br>//console.log(w); <br>var data = new Array(); <br>for(var d = 0; d < num w; d ){ <BR>if(d<w){ <BR>data[d] = ''; <BR>}else{ <BR>data[d] = index; <BR>index ; <BR>} <BR>} <BR>$("#content").html(''); <BR>for(var k =0;k < data.length;k ){ <BR>if(k%7==0){ <BR>$("#content").append("<div id='t" k "' class='date1'>" data[k] "</div><br>"); <br>}else{ <br>$("#content").append("<div id='t" k "' class='date1'>" data[k] "</div>"); <br>} <br>} <br>$("#content > div").mouseover(function(){ <br>if($(this).text()!=''){ <br>$(this).css('background','red'); <br>} <br>}); <br>$("#content > div").mouseout(function(){ <br>if($(this).text()!=''){ <br>$(this).css('background','gray'); <br>} <br>}); <br>} <br><br>$(document).ready(function (){ <br>for(var t = 1970; t < 2999; t ){ <BR>$("#yearsel").append("<option value ='" t "'>" t "</option>"); <br>} <br>for(var y = 1; y < 13;y ){ <BR>$("#monthsel").append("<option value ='" y "'>" y "</option>"); <br>} <br>var year = new Date().getFullYear(); <br>var month = new Date().getMonth() 1; <br>var day = new Date().getDate(); <br>var w = getTime(year,month,1).getDay()-1; <br>var num = day w -1; <br>$("#yearsel").change(function(){ <br>year = $("#yearsel option:selected").text(); <br>month = $("#monthsel option:selected").text(); <br>view(year,month); <br>}); <br>$("#monthsel").change(function(){ <br>year = $("#yearsel option:selected").text(); <br>month = $("#monthsel option:selected").text(); <br>view(year,month); <br>}); <br>var oDate = ['星期一','星期二','星期三','星期四','星期五','星期六','星期日',]; <br>for(var i = 0;i < 7;i ){ <BR>$("#title").append("<div class='date'><b>" oDate[i] "</b></div>"); <br>} <br>$("#yearsel option[value='" year "']").attr("selected", true); <br>view(year,month); <br>//标记当前日期 <br>$("#t" num).css('background','yellow'); <br>}); <br></script>