jquery實(shí)現(xiàn)手風(fēng)琴展開效果
本文實(shí)例為大家分享了jquery實(shí)現(xiàn)手風(fēng)琴展開效果的具體代碼,供大家參考,具體內(nèi)容如下
手風(fēng)琴模式實(shí)現(xiàn)方式:
dom層代碼:
<div class="accordionWrap"> ? ? ? ? <div class="wrap"> ? ? ? ? <div class="title"> ? ? ? ? ? ? <span>內(nèi)容一</span> ? ? ? ? ? ? <span class="arrow slideTog"></span> ? ? ? ? </div> ? ? ? ? <div class="accordionCon"> ? ? ? ? ? ? <div> ? ? ? ? ? ? ? ? <p>錦瑟無端五十弦,一弦一柱思華年。</p> ? ? ? ? ? ? ? ? <p>莊生曉夢(mèng)迷蝴蝶,望帝春心托杜鵑。</p> ? ? ? ? ? ? ? ? <p>滄海月明珠有淚,藍(lán)田日暖玉生煙。</p> ? ? ? ? ? ? ? ? <p>此情可待成追憶?只是當(dāng)時(shí)已惘然。</p> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="moreCon" style="display:none"> ? ? ? ? ? ? ? ? <p>相見時(shí)難別亦難,東風(fēng)無力百花殘。</p> ? ? ? ? ? ? ? ? <p>春蠶到死絲方盡,蠟炬成灰淚始干。</p> ? ? ? ? ? ? ? ? <p>曉鏡但愁云鬢改,夜吟應(yīng)覺月光寒。</p> ? ? ? ? ? ? ? ? <p>蓬山此去無多路,青鳥殷勤為探看。</p> ? ? ? ? ? ? </div> ? ? ? ? </div> ? ? ? ? </div> ? ? ? ? <div class="wrap"> ? ? ? ? ? ? <div class="title"> ? ? ? ? ? ? ? ? <span>內(nèi)容一</span> ? ? ? ? ? ? ? ? <span class="arrow slideTog"></span> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="accordionCon"> ? ? ? ? ? ? ? ? <div> ? ? ? ? ? ? ? ? ? ? <p>錦瑟無端五十弦,一弦一柱思華年。</p> ? ? ? ? ? ? ? ? ? ? <p>莊生曉夢(mèng)迷蝴蝶,望帝春心托杜鵑。</p> ? ? ? ? ? ? ? ? ? ? <p>滄海月明珠有淚,藍(lán)田日暖玉生煙。</p> ? ? ? ? ? ? ? ? ? ? <p>此情可待成追憶?只是當(dāng)時(shí)已惘然。</p> ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? <div class="moreCon" style="display:none"> ? ? ? ? ? ? ? ? ? ? <p>相見時(shí)難別亦難,東風(fēng)無力百花殘。</p> ? ? ? ? ? ? ? ? ? ? <p>春蠶到死絲方盡,蠟炬成灰淚始干。</p> ? ? ? ? ? ? ? ? ? ? <p>曉鏡但愁云鬢改,夜吟應(yīng)覺月光寒。</p> ? ? ? ? ? ? ? ? ? ? <p>蓬山此去無多路,青鳥殷勤為探看。</p> ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? </div> ? ? ? ? </div> ? ? ? ? <div class="wrap"> ? ? ? ? ? ? <div class="title"> ? ? ? ? ? ? ? ? <span>內(nèi)容一</span> ? ? ? ? ? ? ? ? <span class="arrow slideTog"></span> ? ? ? ? ? ? </div> ? ? ? ? ? ? <div class="accordionCon"> ? ? ? ? ? ? ? ? <div> ? ? ? ? ? ? ? ? ? ? <p>錦瑟無端五十弦,一弦一柱思華年。</p> ? ? ? ? ? ? ? ? ? ? <p>莊生曉夢(mèng)迷蝴蝶,望帝春心托杜鵑。</p> ? ? ? ? ? ? ? ? ? ? <p>滄海月明珠有淚,藍(lán)田日暖玉生煙。</p> ? ? ? ? ? ? ? ? ? ? <p>此情可待成追憶?只是當(dāng)時(shí)已惘然。</p> ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? ? ? <div class="moreCon" style="display:none"> ? ? ? ? ? ? ? ? ? ? <p>相見時(shí)難別亦難,東風(fēng)無力百花殘。</p> ? ? ? ? ? ? ? ? ? ? <p>春蠶到死絲方盡,蠟炬成灰淚始干。</p> ? ? ? ? ? ? ? ? ? ? <p>曉鏡但愁云鬢改,夜吟應(yīng)覺月光寒。</p> ? ? ? ? ? ? ? ? ? ? <p>蓬山此去無多路,青鳥殷勤為探看。</p> ? ? ? ? ? ? ? ? </div> ? ? ? ? ? ? </div> ? ? ? ? </div> </div>
css代碼:
?.accordionWrap{ ? ? width: 218px; ? ? background:#1890ff; ? ? border-radius: 4px; ? ? position:absolute; ? ? left: 10px; ? ? top: 50px; ? ? padding: 10px; ? ? box-sizing: border-box; ? ? .wrap{ ? ? ? ? line-height: 18px; ? ? ?.title{ ? ? ? ? span{ ? ? ? ? font-size: 12px; ? ? ? ? font-family: SourceHanSansCN-Regular, SourceHanSansCN; ? ? ? ? font-weight: 400; ? ? ? ? color: #fff; ? ? ? ? ?} ? ? ? ? ? ?.arrow{ ? ? ? ? ? ? width: 12px; ? ? ? ? ? ? height: 7px; ? ? ? ? ? ? background:url("../img/arrow.svg") no-repeat; ? ? ? ? ? ? background-size: 100% 100%; ? ? ? ? ? ? float:right; ? ? ? ? ? ? margin-top: 5px; ? ? ? ? ? ? transform: rotate(180deg); ? ? ? ? ? ? cursor: pointer; ? ? ? ? ? ? transition: all 0.5s; ? ? ? ? } ? ? ? ?.slideTogExchange { ? ? ? ? ? ? width: 12px; ? ? ? ? ? ? height: 7px; ? ? ? ? ? ? background: url('../img/arrow.svg') no-repeat; ? ? ? ? ? ? background-size: 100% 100%; ? ? ? ? ? ? float:right; ? ? ? ? ? ? margin-top: 10px; ? ? ? ? ? ? cursor: pointer; ? ? ? ? ? ? transform: rotate(0deg); ? ? ? ? ? } ? ? ?} ? ? ?.accordionCon{ ? ? ? ? ?border-top: 1px dashed #45fff8; ? ? ? ? ?border-bottom: 1px solid #dddddd; ? ? ? ? p{ ? ? ? ? font-size: 12px; ? ? ? ? font-family: SourceHanSansCN-Regular, SourceHanSansCN; ? ? ? ? font-weight: 400; ? ? ? ? color: #fff; ? ? ? ? } ? ? ? ? .moreCon{ ? ? ? ? ? ? p{ ? ? ? ? ? ? color: #45FFF8 !important; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? } ? ? } ?}
js操作dom的時(shí)候一定要注意層級(jí)之間的關(guān)系
?$(function () { ? ? // 點(diǎn)擊箭頭展開隱藏的內(nèi)容 ? ? ?$(".slideTog").click(function () { ? ? ?var hasClass = $(this).hasClass('slideTogExchange') ? ? ? if (hasClass) { $(this).parent().siblings('.accordionCon').children('.moreCon').slideUp() ?$(this).removeClass('slideTogExchange') ?} else { ? ? ? ? ? $(this).parent().siblings('.accordionCon').children('.moreCon').slideDown() ?$(this).addClass('slideTogExchange') ? ? ? ? ? ? } ? ? ? $(this).parents('.wrap').siblings('.wrap').children('.accordionCon').children('.moreCon').slideUp().removeClass('slideTogExchange') ? ? $(this).parents('.wrap').siblings('.wrap').find('.slideTog').removeClass('slideTogExchange') ? ? ? ? }); ? ? })
實(shí)現(xiàn)效果如下:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- jQuery Easyui使用(一)之可折疊面板的布局手風(fēng)琴菜單
- jQuery實(shí)現(xiàn)的簡(jiǎn)單手風(fēng)琴效果示例
- jquery插件制作 手風(fēng)琴Panel效果實(shí)現(xiàn)
- jQuery制作效果超棒的手風(fēng)琴折疊菜單
- 基于Jquery代碼實(shí)現(xiàn)手風(fēng)琴菜單
- 基于jquery的slideDown和slideUp做手風(fēng)琴
- jquery實(shí)現(xiàn)手風(fēng)琴效果實(shí)例代碼
- jquery手風(fēng)琴特效插件
- Jquery組件easyUi實(shí)現(xiàn)手風(fēng)琴(折疊面板)示例
- jquery超簡(jiǎn)單實(shí)現(xiàn)手風(fēng)琴效果的方法
相關(guān)文章
jquery+ajax實(shí)現(xiàn)跨域請(qǐng)求的方法
這篇文章主要介紹了jquery+ajax實(shí)現(xiàn)跨域請(qǐng)求的方法,詳細(xì)介紹了前臺(tái)及后臺(tái)的處理方法,是非常實(shí)用的技巧,需要的朋友可以參考下2015-01-01input輸入框內(nèi)容實(shí)時(shí)監(jiān)測(cè)(附代碼)
這篇文章主要介紹了如何實(shí)時(shí)監(jiān)測(cè)input輸入框內(nèi)容,具體操作步驟大家可查看下文詳細(xì)講解,感興趣的小伙伴們可以參考一下。2017-08-08jquery寫個(gè)checkbox——類似郵箱全選功能
最近在學(xué)習(xí)jquery,今天抽空用jquery寫個(gè)checkbox——類似郵箱全選功能,感興趣的你可以參考下哈,希望可以幫助到你2013-03-03jQuery插件實(shí)現(xiàn)適用于移動(dòng)端的地址選擇器
本文給大家分享的是一個(gè)jQuery插件,實(shí)現(xiàn)的是適用于移動(dòng)端的地址選擇器,有需要的小伙伴可以拿走參考下。2016-02-02jQuery實(shí)現(xiàn)簡(jiǎn)單的滑動(dòng)導(dǎo)航代碼(移動(dòng)端)
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單的滑動(dòng)導(dǎo)航代碼,適合用于移動(dòng)端。需要的朋友可以參考下2017-05-05jQuery + Flex 通過拖拽方式動(dòng)態(tài)改變圖片的代碼
功能終于告一段落了,實(shí)現(xiàn)了預(yù)期的功能。遇到了一個(gè)小麻煩,js 會(huì)把某些變量( 如果你是通過對(duì)象的方式傳遞的,將在傳遞之后丟失類型信息 ,后面*號(hào)部分)2011-08-08Easyui和zTree兩種方式分別實(shí)現(xiàn)樹形下拉框
最近工作中需要用到樹形下拉框,因?yàn)轫?xiàng)目中樹形結(jié)構(gòu)使用的是zTree,效果不是很好看,于是想著使用easyui的comboTree,雖然效果達(dá)到了,但是風(fēng)格和bootstrap不搭,下面把這兩種方式的效果分享到腳本之家平臺(tái)供大家參考2017-08-08