2016-03-23 6 views
-1

私はこれを使用すると下のコードを使用しています。その代わりに、ユーザーがクリックしたときに私はそれは私はあなたが使用して、あなたのドロップダウン要素のposition属性を変更する必要があります。このクラスをオーバーレイする

jQuery(function($) { 
    $('dd').hide() 
    $(".navigation dt").click(function() { 
    if ($(this).next('dd').is(":visible")) { 
     $(this).next('dd').slideToggle('slow').toggleClass('close'); 
    } else { 
     $(this).next('dd').slideToggle('slow').toggleClass('close'); 
    } 
    }); 
}); 
+0

さらなるアドバイスが必要な場合は、HTMLコードを追加する必要があります。 –

答えて

0

をacheiveどのようにドロップダウンではないの切り替えを示しDIVの(Z-インデックス)をオーバーレイしたいですposition: absolute

私はposition: relativeを使用して、その親にドロップダウンposition: absolute位置決めさを使用して、非常に基本的な例を作成しました:

<div id="content"> 
    <div id="button"><!-- dropdown toggle --></div> 
    <div id="subcontent"> 
    <!-- dropdown content --> 
    </div> 
</div> 

これは、jQueryのスニペットのための提案です:

$(document).ready(function(){ 
    //hide the div '#subcontent' 
    $('#subcontent').hide(); 
    //create click function for subcontent 
    $('#button').click(function(){ 
    $('#subcontent').stop().slideToggle(); 
    }); 
}); 

JS FIDDLE DEMO

これらを重要なものとして使用するには位置属性を消去する。あなたはそれについてat w3schoolsを読むことができます。

+1

あなたの答えの中に関連コードを入れてください。 – Blazemonger

+0

@Blazemongerあなたは正しいです! –

関連する問題