妙味课堂基础篇0_3代码

1、日历

  • 1

    JAN

  • 2

    FER

  • 3

    MAR

  • 4

    APR

  • 5

    MAY

  • 6

    JUN

  • 7

    JUL

  • 8

    AUG

  • 9

    SEP

  • 10

    OCT

  • 11

    NOV

  • 12

    DEC

1月活动

快过年了,大家可以商量着去哪玩吧~

<!DOCTYPE html PUBLIC "-//W3C//h2D XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/h2D/xhtml1-transitional.h2d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript简易日历 - 妙味课堂 - www.miaov.com</title>
<style type="text/css">
    * { padding: 0; margin: 0; }
li { list-style: none; }
body { background: #f6f9fc; font-family: arial; }

.calendar { width: 210px; margin: 0 auto; padding: 10px 10px 20px 20px; background: #eae9e9; }
.calendar ul { width: 210px; overflow: hidden; padding-bottom: 10px; }
.calendar li { float: left; width: 58px; height: 54px; margin: 10px 10px 0 0; border: 1px solid #fff; background: #424242; color: #fff; text-align: center; cursor: pointer; }
.calendar li h2 { font-size: 20px; padding-top: 5px; }
.calendar li p { font-size: 14px; }

.calendar .active { border: 1px solid #424242; background: #fff; color: #e84a7e; }
.calendar .active h2 { }
.calendar .active p { font-weight: bold; }

.calendar .text { width: 178px; padding: 0 10px 10px; border: 1px solid #fff; padding-top: 10px; background: #f1f1f1; color: #555; }
.calendar .text h2 {font-size: 14px; margin-bottom: 10px; }
.calendar .text p { font-size: 12px; line-height: 18px; }
</style>
</head>
<body>
    <div id="tab" class="calendar">

        <ul>
            <li class="active"><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>JUN</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 class="text">
            <h2>1月活动</h2>
            <p>快过年了,大家可以商量着去哪玩吧~</p>
        </div>

    </div>
<script type="text/javascript">
var innerText=
[
    "快过年了,大家可以商量着去哪玩吧~",
    "精通JavaScript开发课程 - 结课标准 - 有十条标准可让大家修练成JS高手……",
    "妙味茶馆(bbs.miaov.com),正式开张,它看起来是论坛,其实是个技术驿站,分成了五个版块:视频教程、妙味生活秀、特效兜儿、技术交流、妙味聊吧",
    "精通各种DOM类应用,熟练掌握面向对象编程思想(OOP)、熟悉JS面向对象开发方式 - 妙味课堂 - www.miaov.com",
    "熟练掌握AJAX技术及相关应用(例如:新浪微博级应用) - 妙味课堂 - www.miaov.com",
    "可以独立写出类似jQuery的小型库(支持各类选择符、事件类、DOM、自定义动画animate、AJAX……) - 妙味课堂 - www.miaov.com",
    "精通JS运动特效技术,能完整实现各类网站所有动画特效,如 妙味课堂 官网 - 妙味课堂 - www.miaov.com",
    "掌握JS调试及优化技术、能兼容所有浏览器 - 妙味课堂 - www.miaov.com",
    "精通JS事件对象及事件的工作机制,并能完成各类跨平台应用模块的开发 - 妙味课堂 - www.miaov.com",
    "能独立开发表现和性能都很优秀的RIA应用 - 妙味课堂 - www.miaov.com",
    "了解后台编程的相关知识,能够和后台工程师配合完成大型交互应用 - 妙味课堂 - www.miaov.com",
    "熟悉正则表达式的编写、应用及高级表单验证技术 - 妙味课堂 - www.miaov.com"
];
    window.onload = function(){
        var lis = document.getElementsByTagName("li");
        var texts = document.getElementsByClassName("text");
 
        for (var i = 0; i < lis.length; i++) {
            lis[i].index = i;
            lis[i].onmouseover = function(){
                for (var i = 0; i < lis.length; i++) {
                    lis[i].className = "";
                }    
                lis[this.index].className = "active";           
                texts[0].innerHTML = "<h2>"+(this.index+1)+"月活动</h2>"
                                    +"<p>"+innerText[this.index]+"</p>"                                   ;           
        }

    }
}
</script>
</body>
</html>
2、时间
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <title>get时间</title>
</head>
<body>
<div><p id="p"> </p></div>
</body>
<script type="text/javascript">
    window.onload = function(){
    var p = document.getElementById("p");
    show(); setInterval(show,1000);
    function toDouble(n){
        if(n>10){
            return n;
        }else{
            return "0"+n;
        }
    }
    function getWeekDay(n){
        switch(n){
            case 0:
                return "星期日";
            case 1:
                return "星期一";
            case 2:
                return "星期二";
            case 3:
                return "星期三";
            case 4:
                return "星期四";
            case 5:
                return "星期五";
            case 6:
                return "星期六";
        }
    }
    function show(){
     var getdate = new Date;
     var year = getdate.getFullYear();
     var month = getdate.getMonth()+1;
     var date = getdate.getDate();
     var day = getdate.getDay();
     var hour = getdate.getHours();
     var minute = getdate.getMinutes();
     var second = getdate.getSeconds();
     p.innerHTML = year+"年"+month+"月"+date+"日"+getWeekDay(day)+"<br/>"+toDouble(hour)+"时"+toDouble(minute)+"分"+toDouble(second)+"秒";
    
    }
}    
</script>
</html>

 

 

 

posted @ 2016-07-22 13:47  阿木木Superstar  阅读(177)  评论(0编辑  收藏  举报