2013-12-14 147 views
0

我試圖讓我點擊一個圖標時切換菜單,但它不工作。我懷疑它與選擇器有關。下面是代碼... HTML不切換菜單

<div class="bild"> 
     <img src="face_kopia.png" class="ikon"/> 
    </div> 
    <div class="meny"> 
     <a href="">Home</a> 
     <a href="">About</a> 
     <a href="">Gallery</a> 
    </div> 

JQUERY

$(document).ready(function(){ 
     //Hide the tooglebox when page load 
     $(".meny").hide(); 
     //slide up and down when hover over 
     $(".ikon").hover(function(){ 
     // slide toggle effect set to slow you can set it to fast too. 
     $(this).next(".meny").slideToggle("slow"); 
     return true; 
     }); 
     }); 

回答

0

當您更改

$(this).next(".meny").slideToggle("slow"); 

$(".meny").slideToggle("slow"); 

它的工作原理

+0

謝謝!這使它工作。 – Delal

0

你的說法是不正確的

http://jsfiddle.net/UQTY2/204/

$(document).ready(function() { 
    //Hide the tooglebox when page load 
    $(".meny").hide(); 
    //slide up and down when hover over 
    $(".ikon").hover(function() { 
     // slide toggle effect set to slow you can set it to fast too. 
     $(".meny").slideToggle("slow"); 
     return true; 
    },function(){ 
     $(".meny").slideToggle("slow"); 
    }); 
}); 
0
$(document).ready(function(){ 
    //Hide the tooglebox when page load 
    $(".meny").hide(); 
    //slide up and down when hover over 
    $(".ikon").hover(function(){ 
    // slide toggle effect set to slow you can set 
    $('.meny').slideToggle("slow"); 
}); 
}); 

這裏是工作示例
http://jsfiddle.net/5x7xv/9/