2012-12-16 65 views
0

我需要類的'兩個和三個'在頁面加載後立即隱藏,並且能夠再次單擊菜單將其向下滑動,我遇到了以下代碼問題:jQuery slideUp和slideDwon問題

$(document).ready(function() 
{ 

$('.two, .three').slideUp('slow'); 

$('.active_wrapper').click(function(){ 
    $('.two, .three').slideDown('slow'); 
}); 

}); 

HTML

<div class="nav_wrapper"> 

    <div class="active_wrapper one"><a class="active" href="">home</a></div> 

    <div class="two"><a href="about.html">about</a></div> 

    <div class="three"><a href="project.html">project</a></div> 

</div> 

回答

1

嘗試像這樣 - DEMO

$(document).ready(function() 
{ 

$('.two, .three').slideUp('slow'); 

$('.active_wrapper').click(function(e){ 
    e.preventDefault(); 
    $('.two, .three').slideToggle('slow'); 
}); 

});​ 
1

這裏與上。二,。三CSS顯示none和除去效果基本show所述的jsfiddle http://jsfiddle.net/L6PkX/

使用

<div class="nav_wrapper"> 

    <div class="active_wrapper one"><a class="active" href="#">home</a></div> 

    <div class="two"><a href="about.html">about</a></div> 

    <div class="three"><a href="project.html">project</a></div> 

</div> 

$(document).ready(function() 
{ 


$('.active_wrapper').click(function(){ 
    $('.two, .three').slideDown('slow'); 
}); 

}); 

.two, .three{ 
    display: none; 
}}