這里結(jié)合實(shí)例形式總結(jié)分析了jQuery中slidedown與slideup方法用法。分享給大家供大家參考,具體如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <style type="text/css"> *{font-size:12px;} div{width:600px;margin:auto;} #control{background-color:gold;padding:10px;margin-bottom:10px;} </style> <script src="../js/jquery-1.5.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#btnslideDown").click(function () { $("#message").slideDown(1000); }); $("#btnslideUp").click(function () { $("#message").slideUp(1000); }); //*****舉例1 // $("#btnToggle").click(function () { // $("#message").slideToggle(1000); // }); //*****舉例2 動(dòng)畫(huà)函數(shù)都可以傳遞回調(diào)函數(shù),即動(dòng)畫(huà)執(zhí)行完畢后會(huì)執(zhí)行這個(gè)函數(shù) $("#btnToggle").click(function () { $("#message").slideToggle(1000, function () { alert('我執(zhí)行完畢了!'); }); }); }); </script></head><body> <div id="control"> <input id="btnslideDown" type="button" value="展開(kāi)div" /> <input id="btnslideUp" type="button" value="收起div" /> <input id="btnToggle" type="button" value="切換" /> </div> <div id="message"> mouseover、mouseenter的區(qū)別:div里套div。見(jiàn)備注。和事件冒泡有關(guān)系。<br /> 不論鼠標(biāo)指針穿過(guò)被選元素或其子元素,都會(huì)觸發(fā) mouseover 事件 <br /> 只有在鼠標(biāo)指針穿過(guò)被選元素時(shí),才會(huì)觸發(fā) mouseenter 事件(穿過(guò)子元素不會(huì)觸發(fā)) </div></body></html>更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《jQuery窗口操作技巧總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jquery中Ajax用法總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見(jiàn)經(jīng)典特效匯總》、《jQuery動(dòng)畫(huà)與特效用法總結(jié)》及《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注