zoukankan      html  css  js  c++  java
  • 寒假学习笔记(11)

    JS学习笔记

    7.选项卡.html

    先清空所有按钮,再为选中的按钮添加样式

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
        #div1 div{width: 200px; height: 100px; background: lightgrey; display: none;}
        .active{background: yellow;}
        </style>
        <script>
        window.onload = function ()
        {
            var oDiv=document.getElementById('div1');
            var aBtn=document.getElementsByTagName('input');
            var aDiv=oDiv.getElementsByTagName('div');
     
            for(var i=0;i<aBtn.length;i++)
            {
                aBtn[i].index=i;
                    //index是自定义属性,但不能再标签里定义,只能在js里定义
                aBtn[i].onclick=function ()
                {
                    //this代表当前发生事件的元素,即当前点击的按钮就是this
                    //alert(this.value);
                    for(var j=0;j<aBtn.length;j++)
                    {
                        aBtn[j].className=' ';
                        aDiv[j].style.display='none';
                    }
                    this.className='active';
                    aDiv[this.index].style.display='block';
                    
                };
            }
    
    
        };
        </script>
    </head>
    <body>
        <input class="active" type="button" value="盲僧" />
        <input type="button" value="锤石" />
        <input type="button" value="亚索" />
        <input type="button" value="纳尔" />
        <div id="div1">
        <div>Yiku!!!</div>
        <div>QQQQQQ</div>
        <div>Suoligeituo!</div>
        <div>Naer  dada!</div>
        </div>
    
    
    </body>
    </html>
    选项卡

    8.innerHTML

    设置标签里的文字,可以往标签里添加带标签的文字,会直接生成相应的HTML元素

    9.简易年历.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    body{background:skyblue;}
    #tab {height:700px;width:440px;background:gray;margin-left:500px;margin-top:10px;position:absolute;}
    #tab ul{margin-top:20px;}
    #tab ul li{list-style:none;height:100px;width:100px;background:black;float:left;margin:10px;text-align:center;border:1px solid #000;color:white;}
    #tab .active{background:white;color:red;}
    
    .text{background:white;height:150px;width:335px;font-size:15px;margin-top:520px;margin-left:50px;position:relative;border:2px solid blue;padding-left:10px;}
    </style>
    <script>
        window.onload=function ()
        {
            var oDiv=document.getElementById('tab');    
            var aLi=oDiv.getElementsByTagName('li');
            var oTxt=oDiv.getElementsByTagName('div');
            var arr=['一月水上公园一日游','二月过山车','三月vr体验','四月跟女朋友出去玩','五月全国人民在家坐月子'];
    
            for (var i = 0; i < aLi.length; i++) {
                aLi[i].index=i+1;
                aLi[i].onmouseover=function ()
                {
                    for (var i = 0; i < aLi.length; i++) {
                        aLi[i].className=' ';
                    }
                    this.className='active';
                    oTxt[0].innerHTML='<h2>'+this.index+'月活动</h2><p>'+arr[this.index-1]+'</p>';
                };
                
            }
    
        };
    </script>
    </head>
    <body>
    <div id="tab" class="calendar">
        <ul>
            <li class="acrive"><h2>1</h2><p>JAN</p></li>
            <li><h2>2</h2><p>FEB</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>AEP</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">
        </div>
    </div>
    
    
        
    </body>
    </html>
    简易年历
  • 相关阅读:
    如何安装一个高可用K3s集群?
    如何设置一个生产级别的高可用etcd集群
    从架构到部署,全面了解K3s
    这应该是最适合国内用户的K3s HA方案
    在K3s上使用Kong网关插件,开启K3s的无限可能!
    AngularJS 遗留项目的升级改造之路(一)
    Rancher首席架构师解读Fleet:它何以管理百万集群?
    资深首席架构师预测:2021年云计算的8个首要趋势
    简单4步,利用Prometheus Operator实现自定义指标监控
    当年,我的架构师之路差点完蛋,幸亏了它
  • 原文地址:https://www.cnblogs.com/jmdd/p/12296588.html
Copyright © 2011-2022 走看看