jQuery ??? ? ? ?? ????? ??
??? ??? ??? ????? ??? ?????.
??? ??
? ???? ???? ?? ??? ??? ? ??? ????. ????? ???? ?????? ??? ? ????? ?? ??? ??????. | ? ?????? ??? ????? ?????. ?, ???? ?? ??? ??? ??? ???? ????. | 600??? ?? ??? ??? ??????.
$("p").fadeIn("slow"); |
fadeOut ( ??, [??] )???? ??? ?? ???? ?? ??? ????? ???? ????? ?????? ??? ? ?? ??? ??????. | 600???? ???? ??? ??? ??? ?????.
| fadeTo (??, ????, [??])$("p").fadeIn("slow"); |
fadeOut( speed, [callback] ) | 通過不透明度的變化來實(shí)現(xiàn)所有匹配元素的淡出效果,并在動畫完成后可選地觸發(fā)一個回調(diào)函數(shù)。 | 用600毫秒緩慢的將段落淡出:
$("p").fadeOut("slow"); |
fadeTo(speed, opacity, [callback]) | 把所有匹配元素的不透明度以漸進(jìn)方式調(diào)整到指定的不透明度,并在動畫完成后可選地觸發(fā)一個回調(diào)函數(shù)。 | 用600毫秒緩慢的將段落的透明度調(diào)整到0.66,大約2/3的可見度:
$("p").fadeTo("slow", 0.66);$("p").fadeTo("slow", 0.66); |
$("p").fadeTo("??", 0.66);$("p").fadeTo("??", 0.66);
??????????
fadeIn ? fadeOut ??? ??? ????? ??? ??? ???? ??? ? ???? ?? ? ???? ?????.
$("#divPop").fadeIn(200); $("#divPop").fadeOut("fast");
1 ??? ? ? ??
1, jQuery fadeIn () ???
jQuery fadeIn()? ??? ??? ??? ??? ? ?????.
語法:$(selector).fadeIn(speed,callback);
??? ?? ????? ??? ?? ??? ?????. "??", "??" ?? ??? ?? ??? ? ????. ??? ?? ????? ???? ??? ? ??? ??? ?????.
?? ????? ??? ?? ??? ???? fadeIn() ???? ?????.
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-3.1.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeIn(); $("#div2").fadeIn("slow"); $("#div3").fadeIn(3000); }); }); </script> </head> <body> <p>演示帶有不同參數(shù)的 fadeIn() 方法。</p> <button>點(diǎn)擊這里,使三個矩形淡入</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>
2. jQuery fadeOut() ???
jQuery fadeOut() ???? ???? ??? ??? ???? ? ?????. .
語法:$(selector).fadeOut(speed,callback);
??? ?? ????? ??? ?? ??? ?????. "??", "??" ?? ??? ?? ??? ? ????. ??? ?? ????? ???? ??? ? ??? ??? ?????.
?? ????? ??? ?? ??? ???? fadeOut() ???? ?????.
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-3.1.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>演示帶有不同參數(shù)的 fadeOut() 方法。</p> <button>點(diǎn)擊這里,使三個矩形淡出</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>
3. jQuery fadeToggle() ???
jQuery fadeToggle() ???? fadeIn() ? fadeOut( ) ??? ?????. ??? ?? ??? ??? ?? fadeToggle()? ??? ??? ? ??? ?????. ??? ?? ??? ?? ?? fadeToggle()? ??? ??? ?? ??? ?????.
語法:$(selector).fadeToggle(speed,callback);
??? ?? ????? ??? ?? ??? ?????. "??", "??" ?? ??? ?? ??? ? ????. ??? ?? ????? ???? ??? ? ??? ??? ?????.
?? ????? ??? ?? ??? ???? fadeToggle() ???? ?????.
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-3.1.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").fadeToggle(); $("#div2").fadeToggle("slow"); $("#div3").fadeToggle(3000); }); }); </script> </head> <body> <p>演示帶有不同參數(shù)的 fadeToggle() 方法。</p> <button>點(diǎn)擊這里,使三個矩形淡入淡出</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>
4. jQuery fadeTo() ???
jQuery fadeTo() ???? ??? ????(0? 1 ??? ?)? ?? ?????? ?????.
語法:$(selector).fadeTo(speed,opacity,callback);
?? ?? ????? ?? ?? ??? ?????. "??", "??" ?? ??? ?? ??? ? ????. fadeTo() ???? ?? ???? ?? ??? ??? ??? ??? ????(0? 1 ??? ?)? ?????. ??? ?? ????? ??? ??? ? ??? ??? ?????.
?? ????? ??? ????? ???? fadeTo() ???? ?????.
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-3.1.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>演示帶有不同參數(shù)的 fadeTo() 方法。</p> <button>點(diǎn)擊這里,使三個矩形淡出</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>
//設(shè)置彈出層的透明度 $("#divPop").fadeTo(0, 0.66); //讓彈出層透明顯示 if ($("#divPop").css("display") == "none") { $("#divPop").fadeIn(speed); } else { $("#divPop").fadeOut(speed); }
fadeTo? ?? ??? ???? ??? ? fadeIn? ???? ??? ???? fadeTo? ??? ???? ?? ??????.
??? ?????. ???? ? ??? ????? ?? ????? ??? ?? ??? ??? ????.