2012-12-24 21 views
-3

$('.sn').css({'z-index':'-1000'}); (隱藏整個組)加載整個類,並從該類我想顯示或應用css $('#item1').css({'z-index':'1000'});(只顯示一個來自組)從一個元素點擊動態但這不會發生幫助我嗎? 當我使用hide()& show()方法,它工作正常。動態添加和刪除zss索引的css

//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'}); 
    } 

}); 

// onload事件..

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

請你重新格式化你的問題? –

+0

你真的需要看看你的代碼 –

回答

1

你爲什麼不只是使用show()hide()方法呢? Z-index只是改變元素的堆棧順序,只能在positioned elements上運行。所以如果你想使用z-index。將元素position屬性設置爲absolutefixed

瞭解更多關於z-index

所以不是做

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

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

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