jquery實(shí)現(xiàn)手風(fēng)琴案例
手風(fēng)琴案例練習(xí),供大家參考,具體內(nèi)容如下
顯示效果
重點(diǎn):
1.鼠標(biāo)進(jìn)入事件mouseenter 鼠標(biāo)離開事件mouseleave
2. 再執(zhí)行下一次操作前都要先通過.stop() 停止動(dòng)畫
3.sublings()選擇當(dāng)前事件外的兄弟事件
完整代碼
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> *{ margin: 0; padding:0; } img{ width: 500px; height:250px; } .box{ width: 900px; height: 300px; margin: 20px auto; border: 1px solid #808080; } .box ul li{ float: left; list-style: none; overflow: hidden; height: 300px; width: 100px; position: relative; } .text{ background-color:lightsteelblue; opacity: 0.7; text-align: center; height: 50px; width: 100%; line-height: 50px; position: absolute; color: black; bottom: 50px; } .link{ background-color:whitesmoke; font-size: 15px; text-indent: 20px; height:50px ; line-height: 50px; } a{ text-decoration: none; } p{ float: left; } span{ margin: auto 20px; } </style> </head> <body> <div class="box"> <ul> //每一個(gè)li為一個(gè)手風(fēng)琴頁面的顯示內(nèi)容 <li class="show" style="width: 500px;"> <div class="img"> <img class="show" src="img/images/p0.jpg" > </div> <div class="text"> 東大門 </div> <div class="link"> <a href=""> <p>科技</p> <p> <span>科技故事</span> <span>科技故事</span> <span>科技故事</span> </p> </a> </div> </li> <li > <div class="img"> <img src="img/images/p1.jpg" > </div> <div class="text"> 雷陽廣場 </div> <div class="link"> <a href=""> <p>科技</p> <p> <span>科技故事</span> <span>科技故事</span> <span>科技故事</span> </p> </a> </div> </li> <li > <div class="img"> <img src="img/images/p3.jpg" > </div> <div class="text"> 校園石碑 </div> <div class="link"> <a href=""> <p>東大門</p> <p> <span>科技故事</span> <span>科技故事</span> <span>科技故事</span> </p> </a> </div> </li> <li > <div class="img"> <img src="img/images/p4.jpg" > </div> <div class="text"> 鐘樓 </div> <div class="link"> <a href=""> <p>科技</p> <p> <span>科技故事</span> <span>科技故事</span> <span>科技故事</span> </p> </a> </div> </li> <li > <div class="img"> <img src="img/images/p5.jpg" > </div> <div class="text"> 椰林 </div> <div class="link"> <a href=""> <p>科技</p> <p> <span>科技故事</span> <span>科技故事</span> <span>科技故事</span> </p> </a> </div> </li> </ul> </div> </body> <script src="./js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(function(){ var $li=$("ul>li") $li.mouseenter(function () { //鼠標(biāo)移入圖片寬度變?yōu)?00,siblings()把其他兄弟的寬度恢復(fù)默認(rèn)寬度。 //stop():在執(zhí)行每次的事件前都必須停止上次的執(zhí)行的事件,否則會(huì)出現(xiàn)最后一次鼠標(biāo)事件移出后,圖片顯示空白 $(this).stop().animate({width:500}).siblings().stop().animate({width:100}); }); $li.mouseleave(function () { //鼠標(biāo)移出事件 $(this).stop().animate({width:500}); }); }); </script> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- jquery實(shí)現(xiàn)垂直手風(fēng)琴菜單
- jquery實(shí)現(xiàn)垂直手風(fēng)琴導(dǎo)航欄
- jQuery實(shí)現(xiàn)王者榮耀手風(fēng)琴效果
- jQuery實(shí)現(xiàn)手風(fēng)琴效果(蒙版)
- jQuery實(shí)現(xiàn)的簡單手風(fēng)琴效果示例
- jquery應(yīng)用實(shí)例分享_實(shí)現(xiàn)手風(fēng)琴特效
- 簡單實(shí)現(xiàn)jQuery手風(fēng)琴效果
- jquery實(shí)現(xiàn)下拉菜單的手風(fēng)琴效果
- 基于jQuery實(shí)現(xiàn)手風(fēng)琴菜單、層級菜單、置頂菜單、無縫滾動(dòng)效果
- jQuery實(shí)現(xiàn)簡單的手風(fēng)琴效果
相關(guān)文章
jquery實(shí)現(xiàn)通用的內(nèi)容漸顯Tab選項(xiàng)卡效果
這篇文章主要介紹了jquery實(shí)現(xiàn)通用的內(nèi)容漸顯Tab選項(xiàng)卡效果,涉及jquery通過時(shí)間函數(shù)定時(shí)觸發(fā)頁面元素樣式變換的功能,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09easyui Droppable組件實(shí)現(xiàn)放置特效
droppable和draggable有類似的地方,不過區(qū)別點(diǎn)在于前者著重于將元素放進(jìn)某個(gè)容器中,而后者則著重于可拖拽(雖然可能一些效果兩者都可以實(shí)現(xiàn))。而且通過查看easyloader源碼可知道,droppable并不依賴于draggable。2015-08-08jQuery實(shí)戰(zhàn)之仿淘寶商城左側(cè)導(dǎo)航效果
網(wǎng)絡(luò)上很很多這種效果的JS寫法,但是還沒有看見用jQuery寫的,效果實(shí)現(xiàn)很簡單,確切的說是用jquery實(shí)現(xiàn)這個(gè)效果很簡單,這就是jquery的強(qiáng)大和魅力所在。2011-04-04jQuery的三種bind/One/Live/On事件綁定使用方法
jQuery是 一款優(yōu)秀的JavaScript框架,在舊版里主要用bind()方法,在新版里又多了兩種One(),Live(),下面介紹這幾種方法的使用2017-02-02