国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

純js簡單日歷實現代碼

2024-05-06 15:52:45
字體:
來源:轉載
供稿:網友
日歷想必大家都比較熟悉吧,實現的方法有很多種,在本文大家將學會到如何使用js簡單實現日歷,感興趣的朋友可以了解下

復制代碼 代碼如下:


<!doctype html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body,ul,li,h2,p
{
margin:0px;
padding:0xp;
}
#div1
{
width:200px;
height:200px;
background:#ccc;

}
.calendar
{
width:240px;
height:345px;
background:#ccc;
margin:auto;
}
.calendar ul
{
list-style:none;
width:232px;
height:260px;
margin:0px;
padding:0px;
}

.calendar ul li
{
width:45px;
height:65px;
background:#333;
float:left;
display:inline;
margin-left:11px;
margin-top:10px;
border:1px solid #ccc;
text-align:center;
color:#FFF;

}
.calendar ul li:hover
{
border:1px solid #000;

}
.text
{
background:#F96;
margin:10px;
padding-bottom:10px;
height:45px;
}
.text h2
{
display:inline;

}
.active
{
background:#FFF !important;
color:#C03 !important;
}

</style>
<script type="text/javascript">
/* window.onload=function()
{
var oBtn=document.getElementById('btn1');
var oTxt=document.getElementById('txt1');
var oDiv=document.getElementById('div1');
oBtn.onclick=function()
{
oDiv.innerHTML=oTxt.value;
}

}*/
window.onload=function()
{
var aLi= document.getElementsByTagName('li');
var Otxt =document.getElementById('tab').getElementsByTagName('div')[0];
var aDats =['元旦1月1日','2月14日情人節','3月3日全國愛耳日',
'4月1日愚人節','5月1日國際勞動節','6月1日 國際兒童節',
'7月1日中國共產黨誕生日','8月1日中國人民解放軍建軍節','9月10日中國教師節',
'10月1日中華人民共和國國慶節','11月9日消防宣傳日','12月3日世界殘疾人日'
];

var i=0;
for(i=0;i<aLi.length;i++) //for循環歷遍li元素
{
aLi[i].index=i;
aLi[i].onmouseover =function() //添加鼠標指向事件
{

for(i=0;i<aLi.length;i++) //for循環歷遍li元素去掉li樣式
{
aLi[i].className ='';
}
this.className ='active'; //給當前標簽添加active 樣式

Otxt.innerHTML ='<h2>'+(this.index+1)+'</h2>'+'月'+'<p>'+aDats[this.index]+'</p>';
}

}

};

</script>
</head>
<body>

<div>
<ul>
<li><h2>1</h2><p>JAN</p></li>
<li><h2>2</h2><p>FER</p></li>
<li><h2>3</h2><p>MAR</p></li>
<li><h2>4</h2><p>APR</p></li>
<li><h2>5</h2><p>MAY</p></li>
<li><h2>6</h2><p>JUM</p></li>
<li><h2>7</h2><p>JUL</p></li>
<li><h2>8</h2><p>AUG</p></li>
<li><h2>9</h2><p>SEP</p></li>
<li><h2>10</h2><p>OCT</p></li>
<li><h2>11</h2><p>NOV</p></li>
<li><h2>12</h2><p>DEC</p></li>
</ul>
<div>

</div>
</div>
</body>
</html>


效果預覽:

純js簡單日歷實現代碼

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 治多县| 宜宾市| 阿图什市| 本溪市| 浙江省| 天柱县| 金阳县| 郯城县| 建湖县| 聂拉木县| 佛山市| 青海省| 武乡县| 贵港市| 永昌县| 图木舒克市| 漳平市| 永安市| 天峻县| 通榆县| 乐至县| 岑巩县| 边坝县| 大丰市| 沾化县| 云南省| 吴堡县| 巨鹿县| 茌平县| 印江| 汾西县| 丰县| 安福县| 深州市| 嵩明县| 岢岚县| 康保县| 奉贤区| 广安市| 德庆县| 乳山市|