2011-04-26 50 views
1

我已經寫了這個功能是一個水平手風琴,到目前爲止它運行良好,我已經將它添加到外部js文件中,並將其加載到每個頁面中,我想要什麼現在在主頁上,刪除懸停功能,並將顏色設置爲#CCC。我用盡了一切,解開了一個,寬度相同再添懸停....取消某個頁面上的功能

http://uwptestsite.uwpistol.net/menu.html

這裏是測試頁面。

我寫的代碼就在這裏。

// JavaScript Document  

$(document).ready(function(){ 
    $(".letter-b").width(12); 
    $(".letter-b").css({"overflow":"hidden", "position":"relative"});  

$(".letter-b a").hover(
    function() { 
     $(this).parent().stop().animate({"width": "52"}, 300); 
    }, 
    function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
    }); 

    $(".letter-e").width(12); 
    $(".letter-e").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-e a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "83"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
     });  

    $(".letter-h").width(12); 
    $(".letter-h").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-h a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "53"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
     }); 

    $(".letter-l").width(11); 
    $(".letter-l").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-l a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "54"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "11"}, 300); 
     }); 

    $(".letter-n").width(12); 
    $(".letter-n").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-n a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "43"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
     });   

    $(".letter-o").width(12); 
    $(".letter-o").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-o a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "94"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
     });  

    $(".letter-r").width(12); 
    $(".letter-r").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-r a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "95"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
     }); 


    $(".letter-w").width(17); 
    $(".letter-w").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-w a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "95"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "17"}, 300); 
     }); 


    $(".letter-x").width(12); 
    $(".letter-x").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-x a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "52"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
     }); 

    $(".letter-y").width(12); 
    $(".letter-y").css({"overflow":"hidden", "position":"relative"}); 

    $(".letter-y a").hover(
     function() { 
     $(this).parent().stop().animate({"width": "52"}, 300); 
     }, 
     function() { 
     $(this).parent().stop().animate({"width": "12"}, 300); 
     });  
}); 

我真的爲此而努力,我想我需要禁用的選項,但是這將是使其成爲該林不知道如何做一個插件..我不想每個頁面啓用鏈接項的列表,因爲它的增長速度在一分鐘,所以如果我可以這樣做

$("letter-h").disableAccordion(); 

我希望我做的意義,我知道有人能有一個解決方案,感謝這個!

+1

我在這裏完全錯過了點,但如果你不希望在特定頁面上懸停功能,只是不包括.'js'文件包含'.hover()'func灰。 – andyb 2011-04-26 09:03:20

回答

2

在你不希望使用該插件的頁面(如果你對動態加載根據頁面上的插件)你可以把:

<script type="text/javascript"> 
$(document).ready(function() 
{ 
    $(".letter-a").unbind("mouseenter mouseleave"); 
}); 
</script> 

,來電後包括JS文件

+0

解除綁定(「懸停」)將不起作用。 http://stackoverflow.com/questions/2727570/jquery-unbindhover-does-not-work – YNhat 2011-04-26 09:16:25

+0

編輯,歡呼聲。 – Dormouse 2011-04-26 09:22:34

+0

它的工作原理!太多了! – 2011-04-29 07:08:29

1

您可以使用此代碼:

$("letter-h").unbind('mouseenter mouseleave');