国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表

圖片精選

主站蜘蛛池模板: 泉州市| 泽州县| 延川县| 潍坊市| 富阳市| 磐石市| 通许县| 大庆市| 无极县| 平昌县| 滦南县| 康平县| 正宁县| 高安市| 山阳县| 隆德县| 峨眉山市| 新河县| 灌南县| 蓬莱市| 嫩江县| 济阳县| 赤水市| 金湖县| 三河市| 都安| 铜川市| 怀柔区| 西乡县| 长兴县| 柳林县| 文水县| 烟台市| 勐海县| 杨浦区| 安溪县| 石林| 龙陵县| 潮安县| 淮北市| 黔西县|