jQuery基本動(dòng)畫效果
基本動(dòng)畫效果
show(spend,[callback]):顯示隱藏的匹配元素
hide(spend,[callback]):隱藏顯示的元素
toggle(switch):根據(jù)switch參數(shù)切換元素的可見狀態(tài)(true為可見,false為隱藏)。
toggle(spend,[callback]):以優(yōu)雅的動(dòng)畫切換所有匹配的元素可見狀態(tài)
<!DOCTYPE html> <html> <head> <title>php.cn</title> <meta charset="utf-8" /> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script> function f1(){ //隱藏 hidden //hide([時(shí)間參數(shù) 毫秒級(jí)][,處理函數(shù)]) $('div').hide(3000,function(){ alert('我消失了,你能看到么'); }); } function f2(){ //顯示 show //show([時(shí)間參數(shù) 毫秒級(jí)][,處理函數(shù)]) $('div').show(3000,function(){ alert('我又回來(lái)了'); }); } function f3(){ $('div').toggle(2000); } </script> <style type="text/css"> div {width:300px; height:200px; background-color:yellow;} </style> </head> <body> <div></div> <input type="button" value="隱藏" onclick="f1()" /> <input type="button" value="顯示" onclick="f2()" /> <input type="button" value="開關(guān)" onclick="f3()" /> </body> </html>