2017-6-2 jQuery 動畫

來源:互聯網
上載者:User

標籤:file   strong   anim   nbsp   down   gre   animate   head   hit   

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>     <script src="js/jquery-1.7.1.min.js"></script>    <title></title>    <style type="text/css">        .div1         {            width:200px;            height:200px;            background-color:red;            float:left;            margin:20px 20px;        }    </style>   </head><body>    <input type="button" value="btn1" id="btn1" />    <div class="div1"></div>    <div class="div1"></div></body></html><script type="text/javascript">    //隱藏顯示:    $("#btn1").click(function () {        if ($(".div1").css(‘display‘) == ‘block‘) {            $(".div1").hide();        }        else        {            $(".div1").show();        }    });    //捲簾門效果:    $("#btn1").click(function () {        if ($(".div1").css(‘display‘) == ‘block‘) {            $(".div1").slideUp();        }        else {            $(".div1").slideDown();        }    });   // 淡入淡出效果:    $("#btn1").click(function () {        if ($(".div1").css(‘display‘) == ‘block‘) {            $(".div1").fadeOut();        }        else {            $(".div1").fadeIn();        }    });    //自訂動畫:    $("#btn1").click(function () {        $(".div1").animate({width:"500px",height:"800"},1000);    });</script>

下拉式功能表:

 

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <script src="js/jquery-1.7.1.min.js"></script>    <title></title>    <style type="text/css">        .div1         {            position:relative;            width:100px;            height:50px;            background-color:red;            float:left;          margin-left:20px;        }        .div2         {            position:absolute;            width:100%;            height:0px;            top:50px;            background-color:green;        }    </style>   </head><body>        <div class="div1">        <div class="div2"></div>    </div>    <div class="div1">        <div class="div2"></div>    </div>     <div class="div1">        <div class="div2"></div>    </div>     <div class="div1">        <div class="div2"></div>    </div>     <div class="div1">        <div class="div2"></div>    </div></body></html><script type="text/javascript">    $(".div1").mousemove(function ()    {        var aa = $(this).children(".div2:eq(0)");        aa.stop().animate({ height: "300px" }, 100, function ()        {            aa.css("background-color","blue");        });    });    $(".div1").mouseout(function () {        var aaa = $(this).children(".div2:eq(0)");        aaa.stop().animate({ height: "0px" }, 100, function () {            aaa.css("background-color", "yellow");        });    });</script>

 

淡入淡出按鈕效果:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>    <script src="js/jquery-1.7.1.min.js"></script>    <script src="js/jquery.color.js"></script>    <title></title>    <style type="text/css">        #div1 {            width:200px;            height:200px;            background-color:red;            font-size:30px;        }    </style></head><body>    <form id="form1" runat="server">    <div id="div1">按鈕        </div>    </form></body></html><script type="text/javascript">    $("#div1").mousemove(function ()    {        $(this).animate({backgroundColor:"green", color:"white"},500);    });    $("#div1").mouseout(function ()    {                $(this).animate({ backgroundColor: "red", color: "black" }, 500);    });</script>

 

2017-6-2 jQuery 動畫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.