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(function(){})與(function(){})(jQuery)之間的區(qū)別
本篇文章主要是對(duì)jQuery(function(){})與(function(){})(jQuery)之間的區(qū)別進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-01-01
jquery插件制作 手風(fēng)琴Panel效果實(shí)現(xiàn)
我們今天要做的是手風(fēng)琴panel,jquery.ui里面有個(gè)叫做accordtion的插件,我們要實(shí)現(xiàn)的效果和他一樣2012-08-08
詳解jQuery的animate動(dòng)畫方法及動(dòng)畫排隊(duì)問題解決
這篇文章主要介紹了jQuery的animate動(dòng)畫方法及動(dòng)畫排隊(duì)問題解決的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用jQuery,感興趣的朋友可以了解下2021-05-05
Web 前端設(shè)計(jì)模式--Dom重構(gòu) 提高顯示性能
首頁(yè)那邊有一個(gè)產(chǎn)品瀏覽的版塊在延遲載入的時(shí)候,將我所有的隱藏幀的項(xiàng)都顯示出來,因?yàn)槁龑?dǎo)致頁(yè)面變形。2010-10-10
Jquery實(shí)現(xiàn)帶動(dòng)畫效果的經(jīng)典二級(jí)導(dǎo)航菜單
導(dǎo)航菜單在網(wǎng)頁(yè)中呈現(xiàn)的頻率還是比較多的,因?yàn)樾Ч喈?dāng)不錯(cuò),接下來為大家介紹下使用jquery實(shí)現(xiàn)經(jīng)典二級(jí)導(dǎo)航菜單,各位童鞋們快來圍觀哦2013-03-03
通過jsonp獲取json數(shù)據(jù)實(shí)現(xiàn)AJAX跨域請(qǐng)求
JSON 可通過 JavaScript 進(jìn)行解析,JSON 數(shù)據(jù)可使用 AJAX 進(jìn)行傳輸,這篇文章主要介紹了通過jsonp獲取json數(shù)據(jù)(實(shí)現(xiàn)AJAX跨域請(qǐng)求),有興趣的可以了解一下。2017-01-01
使用struts2+Ajax+jquery驗(yàn)證用戶名是否已被注冊(cè)
這篇文章主要介紹了使用struts2+Ajax+jquery驗(yàn)證用戶名是否已被注冊(cè)的相關(guān)資料,需要的朋友可以參考下2016-03-03
基于jQuery的一個(gè)擴(kuò)展form序列化到j(luò)son對(duì)象
jQuery沒有直接支持form到j(luò)son的序列化方法,目前網(wǎng)上有一個(gè)實(shí)現(xiàn)是這樣的2010-12-12
jQuery獲取attr()與prop()屬性值的方法及區(qū)別介紹
這篇文章主要介紹了jQuery獲取attr()與prop()屬性值的方法及區(qū)別介紹的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07

