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

首頁(yè) > 語(yǔ)言 > JavaScript > 正文

JQuery animate動(dòng)畫(huà)應(yīng)用示例

2024-05-06 15:39:33
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例講述了JQuery animate動(dòng)畫(huà)。分享給大家供大家參考,具體如下:

滑動(dòng)選項(xiàng)卡

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Title</title>  <style type="text/css">    .btns input{      width: 100px;      height: 40px;      background-color: grey;      border: 0;    }    .btns .current{      background-color: gold;    }    .cons .slides div{      width: 500px;      height: 300px;      background-color: gold;      /*display: none;!*整體都不顯示了*!*/      text-align: center;      line-height: 300px;      font-size: 30px;      float: left;/*把三個(gè)div由隱藏改為浮動(dòng)*/    }    .cons{      width: 500px;      height: 300px;      overflow: hidden; /*超過(guò)cons的slide隱藏*/      position: relative;/*相對(duì)于slide絕對(duì)定位*/    }    .slides{      width: 1500px;      height: 300px; /*把slide加長(zhǎng)*/      position: absolute;/*相對(duì)于cons相對(duì)定位*/    }    .cons .active{      display: block;    }  </style>  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>  <script type="text/javascript">    $(function () {      var $btn=$('.btns input');      var $slides=$('.cons .slides');      // alert($btn.length);      // alert($div.length);      $btn.click(function () {        // 我點(diǎn)擊哪一個(gè)按鈕,$(this)就指的是誰(shuí),而this        //指的是原生的,$(this)指的是JQuery的        // $(this).siblings().removeClass('current');        // $(this).addClass('current');//可以用鏈?zhǔn)秸{(diào)用        $(this).addClass('current').siblings().removeClass('current');        // var num=$(this).index();        // $div.eq($(this).index()).addClass('active').sibling().removeClass('active');        $slides.animate({left:(-500*$(this).index())});      })    })  </script></head><body>  <div class="btns">    <input type="button" name="" value="01" class="current">    <input type="button" name="" value="02">    <input type="button" name="" value="03">  </div>  <div class="cons">    <div class="slides">      <div >選項(xiàng)卡1的內(nèi)容</div>      <div>選項(xiàng)卡2的內(nèi)容</div>      <div>選項(xiàng)卡3的內(nèi)容</div>    </div>  </div></body></html>

將slides下面的div由隱藏改為浮動(dòng),將cons設(shè)置成絕對(duì)定位,將slides改為相對(duì)定位。超過(guò)cons的slides隱藏。
點(diǎn)擊事件發(fā)生之后,相對(duì)定位改變。

animate動(dòng)畫(huà)

$div=$('#div1');$div.animate({  width:300,  height:300},1000,'swing',function () {  alert('done');})
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Title</title>  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>  <script type="text/javascript">    $(function () {      $box=$('.box');      $box.animate({        width:300,        height:300      },1000,'swing',function () {        alert('done');      })    })  </script>  <style type="text/css">    .box{      width: 100px;      height: 100px;      background-color: gold;    }  </style></head><body>  <div class="box"></div></body></html>            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 晋宁县| 尼木县| 巴南区| 都安| 黄浦区| 兴义市| 蕉岭县| 樟树市| 长沙市| 金堂县| 蒲江县| 临江市| 梅河口市| 赤峰市| 平凉市| 赣州市| 砚山县| 平遥县| 宜黄县| 桃园市| 河池市| 青神县| 宁强县| 共和县| 泰兴市| 丹江口市| 广宁县| 建阳市| 原阳县| 安龙县| 曲阜市| 鞍山市| 鄂州市| 临桂县| 昂仁县| 分宜县| 平泉县| 德安县| 宾阳县| 汤阴县| 武安市|