zoukankan      html  css  js  c++  java
  • 2020/6/5 Js简单日历、轮播图和JQuery

    一、轮播图

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    </head>

    <body>
    <img src="img/1.jpg" id="imge" onMouseMove="jieshu()" onMouseOut="kaishi()">
    <input type="button" value="上一页" onClick="up()">
    <input type="button" value="1" onClick="change(this)">
    <input type="button" value="2" onClick="change(this)">
    <input type="button" value="3" onClick="change(this)">
    <input type="button" value="4" onClick="change(this)">
    <input type="button" value="5" onClick="change(this)">
    <input type="button" value="6" onClick="change(this)">
    <input type="button" value="7" onClick="change(this)">
    <input type="button" value="8" onClick="change(this)">
    <input type="button" value="下一页" onClick="next()">
    </body>
    <script type="text/javascript">
    var imgs=["img/1.jpg","img/2.jpg","img/3.jpg","img/4.jpg","img/5.jpg","img/6.jpg","img/7.jpg","img/8.jpg"];
    var img=document.getElementById("imge");
    var index=0;
    var lunbo=null;
    kaishi();
    function change(obj){
    index=obj.value-1;
    img.src=imgs[index];

    }
    function next(){
    if(index==imgs.length-1){
    index=0;
    }else{
    index++;
    }
    img.src=imgs[index];
    }
    function up(){
    if(index==0){
    index=imgs.length
    }else{
    index--;
    }
    img.src=imgs[index];
    }
    function kaishi(){
    lunbo=setInterval(next,2000);
    }
    function jieshu(){
    clearInterval(lunbo);
    }
    </script>
    </html>

    二、简单日历

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>

    </head>

    <body>
    <div id="tab" class="calendar">

    <ul>
    <li class="active" nn="1"><h2>1</h2><p>JAN</p></li>
    <li nn="2"><h2>2</h2><p>FER</p></li>
    <li nn="3"><h2>3</h2><p>MAR</p></li>
    <li nn="4"><h2>4</h2><p>APR</p></li>
    <li nn="5"><h2>5</h2><p>MAY</p></li>
    <li nn="6"><h2>6</h2><p>JUN</p></li>
    <li nn="7"><h2>7</h2><p>JUL</p></li>
    <li nn="8"><h2>8</h2><p>AUG</p></li>
    <li nn="9"><h2>9</h2><p>SEP</p></li>
    <li nn="10"><h2>10</h2><p>OCT</p></li>
    <li nn="11"><h2>11</h2><p>NOV</p></li>
    <li nn="12"><h2>12</h2><p>DEC</p></li>
    </ul>

    <div class="text">
    <h2>1月活动</h2><p>这是1月活动内容</p>
    </div>

    </div>
    </body>
    <script type="text/javascript">
    window.onload=function(){
    var lis=document.getElementById("tab").getElementsByTagName("li");
    for(var i=0;i<lis.length;i++){
    lis[i].onmouseover=over;
    lis[i].onmouseout=out;
    }
    }
    function over(){
    this.className="active";
    var nn=this.getAttribute("nn");
    var content="<h2>"+nn+"月活动</h2><p>这是"+nn+"月活动内容</p>";
    var dd=document.getElementsByClassName("text")[0];
    dd.innerHTML=content;

    }
    function out(){
    this.className="";
    }
    </script>
    </html>

    三、jquery

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <script type="text/javascript" src="jquery-3.5.1.min.js"></script>
    <script type="text/javascript">


    // window.onload=function(){
    // var p1=document.getElementById("p1").innerHTML;
    // console.log(p1);
    // }
    $(function(){
    var p1=$("#p1").html();
    console.log(p1);
    var p2=$(".p2:first").html();
    console.log(p2);
    var p3=$("#p3").html();
    console.log(p3);
    var a=$("[href]").eq(0).html();
    console.log(a);
    var a2=$("[href='baidu']").html();
    console.log(a2);
    $("#p1").html("123");
    })
    </script>
    </head>

    <body>
    <p id="p1">海绵宝宝</p>
    <p class="p2">派大星</p>
    <p class="p2">章鱼哥</p>
    <div id="p3">光头强</div>
    <a href="#">本页</a>
    <a href="baidu">百度</a>
    </body>
    </html>

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style>
    div{
    color: red;
    }
    </style>
    <script type="text/javascript" src="jquery-3.5.1.min.js"></script>
    <script type="text/javascript">
    $(function(){
    $("#uname").blur(function(){
    var uname=$("#uname").val();
    console.log(uname);
    });
    $("#pwd").val("woshinidie");
    console.log($("#pwd").val());
    $("div:first").css("color","yellow");
    $("div:first").css({
    "width":"2000px",
    "height":"2000px",
    "background":"pink"

    });

    var back=$("div:first").css("background");
    console.log(back);

    })

    </script>
    </head>

  • 相关阅读:
    Cs Round#54 E Late Edges
    Cs Round#54 D Spanning Trees
    python装饰器的理解
    java序列化,二进制和数据流
    netty的理解
    CenterOS卸载和安装MYSQL
    oracle的一些问题
    tomcat优化方案(转)
    Selector
    Buffer
  • 原文地址:https://www.cnblogs.com/luzhijin/p/13051473.html
Copyright © 2011-2022 走看看