Copy codeThe Code is as follows:
<! Doctype html> <Head>
<Meta http-equiv = Content-Type content = "text/html; charset = UTF-8">
<Style>
. Main {
Width: 600px;
Height: 350px;
Background: gray;
Margin-left: auto;
Margin-right: auto;
Overflow: hidden;
-Webkit-border-radius: 10px;
-Moz-border-radius: 10px;
}
. Title {
Text-align: center;
}
. Date {
Float: left;
Padding-left: 31px;
}
. Date1 {
Float: left;
Width: 20px;
Height: 20px;
Padding-top: 10px;
Padding-left: 30px;
Padding-right: 30px;
}
. Content {
Margin-left: 25px;
}
</Style>
<Script type = "text/javascript" src = "jquery. min. js"> </script>
<Script>
Function getTime (year, month, day ){
Y = year
M = month
D = day
Var myDate = new Date (year, month-1, day );
Return myDate;
}
Function days_in_month (year, month ){
Y = year;
M = month;
Return 32-new Date (y, m-1, 32). getDate ();
}
Function view (year, month ){
Var w = getTime (year, month, 1). getDay ()-1;
Var num = days_in_month (year, month );
Var index = 1;
// Console. log (w );
Var data = new Array ();
For (var d = 0; d <num + w; d ++ ){
If (d <w ){
Data [d] = '';
} Else {
Data [d] = index;
Index ++;
}
}
$ ("# Content" pai.html ('');
For (var k = 0; k <data. length; k ++ ){
If (k % 7 = 0 ){
$ ("# Content "). append ("<div id = 't" + k + "'class = 'date1'>" + data [k] + "</div> <br> ");
} Else {
$ ("# Content "). append ("<div id = 't" + k + "'class = 'date1'>" + data [k] + "</div> ");
}
}
$ ("# Content> div"). mouseover (function (){
If ($ (this). text ()! = ''){
Watermark (this).css ('background', 'red ');
}
});
$ ("# Content> div"). mouseout (function (){
If ($ (this). text ()! = ''){
Watermark (this).css ('background', 'Gray ');
}
});
}
$ (Document). ready (function (){
For (var t = 1970; t <2999; t ++ ){
$ ("# Yearsel"). append ("<option value = '" + t + "'>" + t + "</option> ");
}
For (var y = 1; y <13; y ++ ){
$ ("# Monthsel"). append ("<option value = '" + y + "'>" + y + "</option> ");
}
Var year = new Date (). getFullYear ();
Var month = new Date (). getMonth () + 1;
Var day = new Date (). getDate ();
Var w = getTime (year, month, 1). getDay ()-1;
Var num = day + w-1;
$ ("# Yearsel"). change (function (){
Year = $ ("# yearsel option: selected"). text ();
Month = $ ("# monthsel option: selected"). text ();
View (year, month );
});
$ ("# Monthsel"). change (function (){
Year = $ ("# yearsel option: selected"). text ();
Month = $ ("# monthsel option: selected"). text ();
View (year, month );
});
Var oDate = ['monday', 'tuesday', 'wedday', 'thurs', 'Friday', 'saturday',];
For (var I = 0; I <7; I ++ ){
$ ("# Title "). append ("<div class = 'date'> <B>" + oDate [I] + "</B> </div> ");
}
$ ("# Yearsel option [value = '" + year + "']"). attr ("selected", true );
View (year, month );
// Mark the current date
$ ("# T" +num).css ('background', 'yellow ');
});
</Script>
</Head>
<Body>
<Div id = "main" class = "main">
<Center> <Select id = "yearsel">
</Select> year
<Select id = "monthsel">
</Select> month <br>
<Div id = "title" class = "title">
</Div>
<Div id = "content" class = "content">
</Div>
</Div>
</Body>
</Html>