最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery 常用特效實(shí)例小結(jié)【顯示與隱藏、淡入淡出、滑動(dòng)、動(dòng)畫(huà)等】

 更新時(shí)間:2020年05月19日 10:23:43   作者:人生如初見(jiàn)_張默  
這篇文章主要介紹了jQuery 常用特效,結(jié)合實(shí)例形式總結(jié)分析了jquery顯示與隱藏、淡入淡出、滑動(dòng)、動(dòng)畫(huà)等常用特效實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery 常用特效。分享給大家供大家參考,具體如下:

顯示與隱藏

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <style type="text/css">
 #content{display: none;}
 </style>
 <script src="jQuery/jquery-1.8.3.js"></script>
 <script type="text/javascript">
    $('#btn').click(function(event) {
     if ($(this).text() === '顯示說(shuō)明') {
     $('#content').show();
            //$('#content').show('slow');//設(shè)置顯示速度,1000為一秒,也可以用fast或slow
            //$('#content').show('slow',function() {
              //$('h3').css('color','red');
            //});//設(shè)置顯示完成后的回調(diào)函數(shù)
     $(this).text('隱藏說(shuō)明');
     } else {
     $('#content').hide();
     $(this).text('顯示說(shuō)明');
     }
    });
   });
 </script>
</head>
<body>
   <img src="images/logo.jpg" alt='logo' style="width: 300px">
   <div>
   <p id="content">百度logo,埃里克森上放聲大哭就會(huì)發(fā)生放聲大哭肌膚時(shí)受到了飛機(jī)上的法律手段無(wú)可奈何花落去</p>
 </div>
   <div style="clear: both">
   <button type="button" name="button" id="btn">顯示說(shuō)明</button>
   </div>
 
</body>
</html>

淡入與淡出

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <style type="text/css">
 #content{display: none;}
 </style>
 <script src="jQuery/jquery-1.8.3.js"></script>
 <script type="text/javascript">
    //1、淡入
    $('#fadeIn').click(function(event) {
     $('#group1 img:first').fadeIn('slow');
     $('#group1 img:eq(1)').fadeIn('fast');
     $('#group1 img:last').fadeIn(3000,function() {
     alert('淡入');
     });
    });
    //2、淡出
    $('#fadeOut').click(function(event) {
     $('#group2 img:first').fadeOut('slow');
     $('#group2 img:eq(1)').fadeOut('fast');
     $('#group2 img:last').fadeOut(3000,function() {
     alert('淡出');
     });
    });
    //3、淡入/淡出結(jié)合
    $('#fadeToggle').click(function(event) {
     $('#group3 img:first').fadeToggle('slow');
     $('#group3 img:eq(1)').fadeToggle('fast');
     $('#group3 img:last').fadeToggle(3000,function() {
     alert('淡入/淡出結(jié)合');
     });
    });
    //4、設(shè)置褪色級(jí)別
    $('#fadeTo').click(function(event) {
     $('#group4 img:first').fadeTo('slow',0.6);
     $('#group4 img:eq(1)').fadeTo('fast',0.4);
     $('#group4 img:last').fadeTo(3000,0.2,function() {
     alert('圖片褪色');
     });
    });
   });
 </script>
 <style>
 #group1 img{display: none;}
 </style>
</head>
<body>
 <div id="group1">
 <button type="button" name="button" id="fadeIn">淡入</button>
 <img src="images/1.png" alt="">
 <img src="images/2.png" alt="" width="100px">
 <img src="images/3.png" alt="">
 </div>
 <div id="group2">
 <button type="button" name="button" id="fadeOut">淡出</button>
 <img src="images/1.png" alt="">
 <img src="images/2.png" alt="" width="100px">
 <img src="images/3.png" alt="">
 </div>
 <div id="group3">
 <button type="button" name="button" id="fadeToggle">淡入/淡出自動(dòng)</button>
 <img src="images/1.png" alt="">
 <img src="images/2.png" alt="" width="100px">
 <img src="images/3.png" alt="">
 </div>
 <div id="group4">
 <button type="button" name="button" id="fadeTo">設(shè)置褪色級(jí)別</button>
 <img src="images/1.png" alt="">
 <img src="images/2.png" alt="" width="100px">
 <img src="images/3.png" alt="">
 </div>
 
</body>
</html>

滑動(dòng)

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>滑動(dòng)效果</title>
 <style>
 #wrap img{width: 100px;}
 /*#content {width: 100px;display: none;}*//*向下滑動(dòng)*/
 </style>
 <script type="text/javascript"></script>
 <script src="jQuery/jquery-1.8.3.min.js"></script>
 <script>
 $(document).ready(function() {
  //1、向下滑動(dòng)
  $('#wrap img').bind('click',function() {
  // $('#content').slideDown('slow');
  $('#content').slideDown('slow',function(event) {
   $('#wrap img').fadeOut('slow',function(event) {
   $(this).attr('src','images/3.png').fadeIn('slow');
   });
  });
  });
  //2、向上滑動(dòng)
  $('#wrap img').bind('click',function() {
  // $('#content').slideUp('slow');
  $('#content').slideUp('slow',function(event) {
   $('#wrap img').fadeOut('slow',function(event) {
   $(this).attr('src','images/3.png').fadeIn('slow');
   });
  });
  });
  //3、展開(kāi)與收起切換
  $('#wrap img').bind('click',function() {
  // $('#content').slideToggle('slow');
  $('#content').slideToggle('slow',function(event) {
   $('#wrap img').fadeOut('slow',function(event) {
   if ($(this).attr('src') == 'images/3.png') {
    $(this).attr('src','images/2.png').fadeIn('slow');
   } else {
    $(this).attr('src','images/3.png').fadeIn('slow');
   }
   });
  });
  });
 });
 </script>
</head>
<body>
 <div id='wrap'>
 <div id='content'>
  <h3>百度</h3>
  <p>要??怂沟胤剿伎季突貜?fù)剞城飄飄㱒發(fā)生糾紛還是葉</p>
 </div>
 <img src="images/2.png" alt="百度">
 </div>
</body>
</html>

動(dòng)畫(huà)實(shí)例

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>動(dòng)畫(huà)</title>
 <style>
 img{width: 0;opacity: 0;}
 .content{display: none;}
 </style>
 <script src="jQuery/jquery-1.8.3.min.js"></script>
 <script type="text/javascript">
 $(document).ready(function() {
  $('#btn').click(function(event) {
  $('img').before('<br>');
                //當(dāng)按鈕內(nèi)容為顯示時(shí),修改按鈕內(nèi)容,顯示圖片和說(shuō)明
  if ($(this).text() == '顯示') {
   $(this).text('隱藏');
   $('img').animate({//動(dòng)畫(huà)屬性對(duì)象(必選)
   width:200,//屬性必須是css屬性,只支持?jǐn)?shù)字型,不支持字體顏色
   opacity:1,//屬性值單位:默認(rèn)為px
   },{//動(dòng)畫(huà)選項(xiàng)屬性(可選)
   duration:3000,
   complete:function(event) {
    $('.content').slideDown(3000);
   }
   });
  } else {//當(dāng)按鈕內(nèi)容為隱藏時(shí),修改按鈕內(nèi)容,隱藏圖片和說(shuō)明
   $(this).text('顯示');
   $('img').animate({//動(dòng)畫(huà)屬性對(duì)象(必選)
   width:0,
   opacity:0,
   },{//動(dòng)畫(huà)選項(xiàng)屬性(可選)
   duration:3000,
   complete:function(event) {
    $('.content').slideUp(3000);
   }
   });
  }
  });
 });
 </script>
</head>
<body>
 <button type="button" name="button" id="btn">顯示</button>
 <img src="images/2.png" alt="baidu">
 <div class="content">
 <p>富士康地方就是看適當(dāng)放寬了;收款方式斯洛伐克但是</p>
 </div>
</body>
</html>

感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運(yùn)行工具http://tools.jb51.net/code/HtmlJsRun測(cè)試上述代碼運(yùn)行效果。

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《jQuery頁(yè)面元素操作技巧匯總》、《jQuery常見(jiàn)事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • JQuery下關(guān)于$.Ready()的分析

    JQuery下關(guān)于$.Ready()的分析

    最近一直在研究JQuery,這個(gè)東西還是很博大精深的.下面分享一下我的學(xué)習(xí)總結(jié).
    2009-12-12
  • 解決jquery appaend元素中id綁定事件失效的問(wèn)題

    解決jquery appaend元素中id綁定事件失效的問(wèn)題

    下面小編就為大家?guī)?lái)一篇解決jquery appaend元素中id綁定事件失效的問(wèn)題。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-09-09
  • 非常有用的40款jQuery 插件推薦(系列二)

    非常有用的40款jQuery 插件推薦(系列二)

    jQuery 是一個(gè)非常優(yōu)秀的 JavaScript 框架,在現(xiàn)在的 Web 開(kāi)發(fā)項(xiàng)目中扮演著重要角色。jQuery 使用簡(jiǎn)單靈活,同時(shí)還有許多成熟的插件可供選擇,它可以幫助你在項(xiàng)目中加入一些非常好的效果,讓網(wǎng)站有更好的可用性和用戶(hù)體驗(yàn)
    2011-12-12
  • 淺談jQuery中replace()方法

    淺談jQuery中replace()方法

    這篇文章主要介紹了jQuery中replace()方法用法,實(shí)例分析了replace()方法的功能、定義及匹配元素去替換指定內(nèi)容的方法,需要的朋友可以參考下
    2015-05-05
  • jQuery之浮動(dòng)窗口實(shí)現(xiàn)代碼(兩種方法)

    jQuery之浮動(dòng)窗口實(shí)現(xiàn)代碼(兩種方法)

    今天公司要求實(shí)現(xiàn)浮動(dòng)窗口效果,自己看了不少資料終于實(shí)現(xiàn)此效果。用jQ實(shí)現(xiàn)浮動(dòng)窗口功能,彈出窗口時(shí)背景變暗.
    2010-09-09
  • jQuery實(shí)現(xiàn)base64前臺(tái)加密解密功能詳解

    jQuery實(shí)現(xiàn)base64前臺(tái)加密解密功能詳解

    這篇文章主要介紹了jQuery實(shí)現(xiàn)base64前臺(tái)加密解密功能,結(jié)合實(shí)例形式分析了jquery.base64.js實(shí)現(xiàn)前臺(tái)base64加密與解密功能的實(shí)現(xiàn)方法,并給出了java實(shí)現(xiàn)后臺(tái)base64加密解密的操作示例對(duì)比驗(yàn)證加密效果,需要的朋友可以參考下
    2017-08-08
  • jQuery中delegate與on的用法與區(qū)別示例介紹

    jQuery中delegate與on的用法與區(qū)別示例介紹

    jQuery1.7中 .delegate()已被.on()取代,下面以示例的方式為大家介紹下jQuery中delegate與on的用法與區(qū)別,感興趣的朋友可以參考下
    2013-12-12
  • jQuery實(shí)現(xiàn)form表單基于ajax無(wú)刷新提交方法實(shí)例代碼

    jQuery實(shí)現(xiàn)form表單基于ajax無(wú)刷新提交方法實(shí)例代碼

    在本篇文章里小編給大家整理了關(guān)于jQuery實(shí)現(xiàn)form表單基于ajax無(wú)刷新提交方法實(shí)例代碼,需要的朋友們參考下。
    2019-11-11
  • ajax+jQuery實(shí)現(xiàn)級(jí)聯(lián)顯示地址的方法

    ajax+jQuery實(shí)現(xiàn)級(jí)聯(lián)顯示地址的方法

    這篇文章主要介紹了ajax+jQuery實(shí)現(xiàn)級(jí)聯(lián)顯示地址的方法,涉及jQuery操作Ajax實(shí)現(xiàn)級(jí)聯(lián)顯示的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2015-05-05
  • jQuery獲取cookie值及刪除cookie用法實(shí)例

    jQuery獲取cookie值及刪除cookie用法實(shí)例

    這篇文章主要介紹了jQuery獲取cookie值及刪除cookie用法,實(shí)例分析了jQuery操作cookie時(shí)域和路徑的作用,以及針對(duì)cookie的讀取與刪除技巧,需要的朋友可以參考下
    2016-04-04

最新評(píng)論

武清区| 蓝山县| 前郭尔| 噶尔县| 文登市| 长汀县| 苍溪县| 枞阳县| 咸宁市| 安图县| 融水| 德昌县| 上杭县| 吴桥县| 澄城县| 崇阳县| 集安市| 九龙坡区| 甘泉县| 鹤峰县| 昂仁县| 进贤县| 策勒县| 浙江省| 皮山县| 达拉特旗| 固镇县| 渭南市| 玉龙| 牙克石市| 济宁市| 延庆县| 芷江| 麦盖提县| 乳山市| 利川市| 鄂州市| 栖霞市| 廉江市| 平江县| 淮南市|