-2

$('.sn').css({'z-index':'-1000'}); (グループ全体を非表示) クラス全体のロード時に、そのクラスから動的に要素をクリックして css $('#item1').css({'z-index':'1000'});(グループから 1 つだけを表示) を表示または適用したいのですが、これは起こりません。hide() & show() メソッドを使用すると、正常に動作します。

//on click ..
$(document).on('click','#slider1prev',function(){   

    selected = selected-1;



    if(my_text != ""){
        $('#noteImage'+selected).css({'z-index':'1000'});
        $('#noteText'+selected).css({'z-index':'1000'});
    }

});

//オンロード..

$('.sn').css({'z-index':'-1000'});
$('.notes').css({'z-index':'-1000'});
4

1 に答える 1

5

show()代わりにandhide()メソッドを使用してみませんか? Z-index は、要素のスタック順序を変更するだけで、 でのみ機能しpositioned elementsます。したがって、z-index を使用する場合。elementspositionプロパティをabsoluteまたは に設定しfixedます。

z-index の詳細を参照してください。

そうする代わりに

.css({'z-index':'1000'});

行う

.css({'position': 'absolute', 'z-index':'1000'});

また

.css({'position': 'fixed', 'z-index':'1000'});
于 2012-12-24T08:32:47.843 に答える