簡體   English   中英

更新我的js手風琴標簽以有選擇地打開和關閉內容

[英]updating my js accordion tabs to selectively open and close content

我創建手風琴的方式是一次只能打開一套內容,我的問題是如何更新代碼,以便單擊活動選項卡並關閉內容? 目前,如果我嘗試關閉活動標簽,則內容會先滑后滑,然后再滑回去?

我確定我以錯誤的方式編寫了此代碼,並希望獲得有關如何增強此http://jsfiddle.net/kyllle/csggQ/1/的所有建議。

凱爾

似乎您正在使事情復雜化:)

您已經做到了, http://jsfiddle.net/csggQ/21/

$(document).ready(function(){
    $('p').hide();

    $('h2').click(function() {

        if($(this).hasClass('active'))
        {
           $(this).removeClass('active');
           $(this).next('p').slideUp(600);
        } else {          
           $('#myContent .active').removeClass('active').next().slideUp(600);
           $(this).addClass('active');
           $(this).next('p').slideDown(600);
        }

    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM