日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > web前端 > htmlcss > jQuery基礎學習(2)(效果)

jQuery基礎學習(2)(效果)

來源:程序員人生   發布時間:2016-07-18 08:21:56 閱讀次數:4633次
  • jQuery效果

a.隱藏效果


  • $(selector).hide(speed,callback);

  • $(selector).show(speed,callback);
    (1)可選的 speed 參數規定隱藏/顯示的速度,可以取以下值:”slow”、”fast” 或毫秒。
    (2)可選的 callback 參數是隱藏或顯示完成后所履行的函數名稱。

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF⑻"> <title></title> <script src="jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".ex .hide").click(function(){ //設置緩慢隱藏 // $(this).parents(".ex").hide("slow"); // }); $(this).parents(".ex").hide("slow",function(){ alert('ddd'); }); }); </script> <style type="text/css"> .ex{ background-color: #e5eecc; padding: 7px; border: solid 1px #c3c3c3; } </style> </head> <body> <h3>中國辦事處</h3> <div class="ex"> <button class="hide" type="button">隱藏</button><br> <p>聯系人:張先生<br/> 北3環中路 100 號<br/> 北京</p> </div> <h3>美國辦事處</h3> <div class="ex"> <button class="hide" type="button">隱藏</button> <p>聯系人:David<br /> 第5大街 200 號<br /> 紐約</p> </div> </body> </html>
$("button").click(function(){ $("p").hide(1000); });

jQuery toggle()

通過 jQuery,您可使用 toggle() 方法來切換 hide() 和 show() 方法。

顯示被隱藏的元素,并隱藏已顯示的元素:

$(document).ready(function(){ $("button").click(function(){ $("p").toggle(); }); }); </script>

b. jQuery Fading 方法


通過 jQuery,您可以實現元素的淡入淡出效果。
jQuery 具有下面4種 fade 方法:

  • fadeIn()
  • fadeOut()
  • fadeToggle()
  • fadeTo()

jQuery fadeIn() 方法

jQuery fadeIn() 用于淡入已隱藏的元素。

語法:

$(selector).fadeIn(speed,callback);

可選的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。

可選的 callback 參數是 fading 完成后所履行的函數名稱

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeIn(); $("#div2").fadeIn("slow"); $("#div3").fadeIn(3000); }); }); </script> </head> <body> <p>演示帶有不同參數的 fadeIn() 方法。</p> <button>點擊這里,使3個矩形淡入</button> <br><br> <div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div> <br> <div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div> <br> <div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div> </body> </html>

jQuery fadeOut() 方法

jQuery fadeOut() 方法用于淡出可見元素。
語法:

$(selector).fadeOut(speed,callback);

可選的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。
可選的 callback 參數是 fading 完成后所履行的函數名稱。

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeOut(); $("#div2").fadeOut("slow"); $("#div3").fadeOut(3000); }); }); </script> </head> <body> <p>演示帶有不同參數的 fadeOut() 方法。</p> <button>點擊這里,使3個矩形淡出</button> <br><br> <div id="div1" style="width:80px;height:80px;background-color:red;"></div> <br> <div id="div2" style="width:80px;height:80px;background-color:green;"></div> <br> <div id="div3" style="width:80px;height:80px;background-color:blue;"></div> </body> </html>

jQuery fadeToggle() 方法

jQuery fadeToggle() 方法可以在 fadeIn() 與 fadeOut() 方法之間進行切換。
如果元素已淡出,則 fadeToggle() 會向元素添加淡入效果。
如果元素已淡入,則 fadeToggle() 會向元素添加淡出效果。
語法:

$(selector).fadeToggle(speed,callback);

可選的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。
可選的 callback 參數是 fading 完成后所履行的函數名稱。

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeToggle(); $("#div2").fadeToggle("slow"); $("#div3").fadeToggle(3000); }); }); </script> </head> <body> <p>演示帶有不同參數的 fadeToggle() 方法。</p> <button>點擊這里,使3個矩形淡入淡出</button> <br><br> <div id="div1" style="width:80px;height:80px;background-color:red;"></div> <br> <div id="div2" style="width:80px;height:80px;background-color:green;"></div> <br> <div id="div3" style="width:80px;height:80px;background-color:blue;"></div> </body> </body> </html>

jQuery fadeTo() 方法

jQuery fadeTo() 方法允許漸變成給定的不透明度(值介于 0 與 1 之間)。
語法:

$(selector).fadeTo(speed,opacity,callback);

必須的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。
fadeTo() 方法中必須的 opacity 參數將淡入淡出效果設置為給定的不透明度(值介于 0 與 1 之間)。
可選的 callback 參數是該函數完成后所履行的函數名稱。

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeTo("slow",0.15); $("#div2").fadeTo("slow",0.4); $("#div3").fadeTo("slow",0.7); }); }); </script> </head> <body> <p>演示帶有不同參數的 fadeTo() 方法。</p> <button>點擊這里,使3個矩形淡出</button> <br><br> <div id="div1" style="width:80px;height:80px;background-color:red;"></div> <br> <div id="div2" style="width:80px;height:80px;background-color:green;"></div> <br> <div id="div3" style="width:80px;height:80px;background-color:blue;"></div> </body> </html>

jQuery 滑動方法

通過 jQuery,您可以在元素上創建滑動效果。
jQuery 具有以下滑動方法:
slideDown()
slideUp()
slideToggle()

jQuery slideDown() 方法

jQuery slideDown() 方法用于向下滑動元素。
語法:

$(selector).slideDown(speed,callback);

可選的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。
可選的 callback 參數是滑動完成后所履行的函數名稱。

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideDown("slow"); }); }); </script> <style type="text/css"> div.panel,p.flip { margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px #c3c3c3; } div.panel { height:120px; display:none; } </style> </head> <body> <div class="panel"> <p>W3School - 領先的 Web 技術教程站點</p> <p>在 W3School,你可以找到你所需要的所有網站建設教程。</p> </div> <p class="flip">請點擊這里</p> </body> </html>

jQuery slideUp() 方法

jQuery slideUp() 方法用于向上滑動元素。
語法:

$(selector).slideUp(speed,callback);

可選的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。
可選的 callback 參數是滑動完成后所履行的函數名稱。

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideUp("slow"); }); }); </script> <style type="text/css"> div.panel,p.flip { margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px #c3c3c3; } div.panel { height:120px; } </style> </head> <body> <div class="panel"> <p>W3School - 領先的 Web 技術教程站點</p> <p>在 W3School,你可以找到你所需要的所有網站建設教程。</p> </div> <p class="flip">請點擊這里</p> </body> </html>

jQuery slideToggle() 方法

jQuery slideToggle() 方法可以在 slideDown() 與 slideUp() 方法之間進行切換。
如果元素向下滑動,則 slideToggle() 可向上滑動它們。
如果元素向上滑動,則 slideToggle() 可向下滑動它們。

$(selector).slideToggle(speed,callback);

可選的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。
可選的 callback 參數是滑動完成后所履行的函數名稱。

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideToggle("slow"); }); }); </script> <style type="text/css"> div.panel,p.flip { margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px #c3c3c3; } div.panel { height:120px; display:none; } </style> </head> <body> <div class="panel"> <p>W3School - 領先的 Web 技術教程站點</p> <p>在 W3School,你可以找到你所需要的所有網站建設教程。</p> </div> <p class="flip">請點擊這里</p> </body> </html>

jQuery動畫

jQuery 動畫 - animate() 方法

jQuery animate() 方法用于創建自定義動畫。
語法:

$(selector).animate({params},speed,callback);

必須的 params 參數定義構成動畫的 CSS 屬性。
可選的 speed 參數規定效果的時長。它可以取以下值:”slow”、”fast” 或毫秒。
可選的 callback 參數是動畫完成后所履行的函數名稱。
//1個實現從左到右移動的動畫
demo1:

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({left:'250px'}); }); }); </script> </head> <body> <button>開始動畫</button> <p>默許情況下,所有 HTML 元素的位置都是靜態的,并且沒法移動。如需對位置進行操作,記得首先把元素的 CSS position 屬性設置為 relative、fixed 或 absolute。</p> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"> </div> </body> </html>

demo2:

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ left:'250px', opacity:'0.5', height:'150px', width:'150px' }); }); }); </script> </head> <body> <button>開始動畫</button> <p>默許情況下,所有 HTML 元素的位置都是靜態的,并且沒法移動。如需對位置進行操作,記得首先把元素的 CSS position 屬性設置為 relative、fixed 或 absolute。</p> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"> </div> </body> </html>

demo3:

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ left:'250px', height:'+=150px', width:'+=150px' }); }); }); </script> </head> <body> <button>開始動畫</button> <p>默許情況下,所有 HTML 元素的位置都是靜態的,并且沒法移動。如需對位置進行操作,記得首先把元素的 CSS position 屬性設置為 relative、fixed 或 absolute。</p> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"> </div> </body> </html>
//屬性的動畫值設置為 "show"、"hide" 或 "toggle": $(document).ready(function(){ $("button").click(function(){ $("div").animate({ height:'toggle' }); }); });

jQuery animate() - 使用隊列功能

默許地,jQuery 提供針對動畫的隊列功能。
這意味著如果您在彼此以后編寫多個 animate() 調用,jQuery 會創建包括這些方法調用的“內部”隊列。然后逐1運行這些 animate 調用。

<!DOCTYPE html> <html> <head> <script src="jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var div=$("div"); div.animate({height:'300px',opacity:'0.4'},"slow"); div.animate({width:'300px',opacity:'0.8'},"slow"); div.animate({height:'100px',opacity:'0.4'},"slow"); div.animate({width:'100px',opacity:'0.8'},"slow"); }); }); </script> </head> <body> <button>開始動畫</button> <p>默許情況下,所有 HTML 元素的位置都是靜態的,并且沒法移動。如需對位置進行操作,記得首先把元素的 CSS position 屬性設置為 relative、fixed 或 absolute。</p> <div style="background:#98bf21;height:100px;width:100px;position:absolute;"> </div> </body> </html> <html> <head> <meta charset="u"> <script src="jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var div=$("div"); div.animate({left:'100px',opacity:'0.6'},"slow"); div.animate({fontSize:'3em',color: '2E9ECE'},"slow"); }); }); </script> </head> <body> <button>開始動畫</button> <p>默許情況下,所有 HTML 元素的位置都是靜態的,并且沒法移動。如需對位置進行操作,記得首先把元素的 CSS position 屬性設置為 relative、fixed 或 absolute。</p> <div style="background:#98bf21;height:100px;width:200px;position:absolute;">HELLO</div> </body> </html>

jQuery stop() 方法

jQuery stop() 方法用于停止動畫或效果,在它們完成之前。
stop() 方法適用于所有 jQuery 效果函數,包括滑動、淡入淡出和自定義動畫。

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script> $(document).ready(function(){ $("#flip").click(function(){ $("#panel").slideDown(5000); }); $("#stop").click(function(){ $("#panel").stop(); }); }); </script> <style type="text/css"> #panel,#flip { padding:5px; text-align:center; background-color:#e5eecc; border:solid 1px #c3c3c3; } #panel { padding:50px; display:none; } </style> </head> <body> <button id="stop">停止滑動</button> <div id="flip">點擊這里,向下滑動面板</div> <div id="panel">Hello world!</div> </body> </html>

jQuery動作的鏈接

<!DOCTYPE html> <html> <head> <script src="/jquery/jquery⑴.11.1.min.js"></script> <script> $(document).ready(function() { $("button").click(function(){ $("#p1").css("color","red").slideUp(2000).slideDown(2000); }); }); </script> </head> <body> <p id="p1">jQuery 樂趣10足!</p> <button>點擊這里</button> </body> </html>
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 国产疯狂做受xxxx高潮 | 欧美日本韩国 | 国产精品第一区 | 欧美精品在线一区 | 黄色毛片视频在线观看 | 亚洲欧美在线播放 | a毛片在线观看 | 成人自拍一区 | 久久日韩| 亚洲精品国产精品国自产观看浪潮 | 99精品国产高清在线观看 | 成人av免费在线 | 精品国产一区二区三区免费 | 国内精品国产成人国产三级粉色 | 国产精品日韩在线观看一区二区 | 一本一本久久a久久精品综合小说 | 中文字幕日韩欧美一区二区三区 | 久久精品99国产精品酒店日本 | 天堂a在线| 久久精品免费 | 九九九亚洲 | 国产精品一区二区三区久久 | 国产一区二区三区片 | 伊人精品成人久久综合软件 | 图片区自拍偷拍 | 国产一区二区三区视频播放 | 欧美一区二区性 | 在线观看视频免费播放 | 麻豆视频一区 | 亚洲国产精品一区二区第一页 | 欧美成人xxx | 麻豆一级| 午夜精品久久久久久久传媒 | 亚洲一区二区黄 | 久久久久无码国产精品一区 | 亚洲成人一区二区三区 | 精品一区一区三区新区乱码 | 国产精品久久久久一级毛片 | 国产二区在线播放 | 精品久久久一区二区 | 久久精品在线观看 |