2014-01-15 67 views
0

我想這個動畫是唯一可能的vom top 0到200當我滾動到201這個點擊動畫被禁用。這是怎麼回事?禁用點擊滾動

我需要這個,因爲我點擊導航它滑到頂部,所以我不能再看到我的導航。

$(window).scroll(function() { 
    if ($(this).scrollTop() < 200) 
    { 
     $("#treest, #treest2, #treest3").click(function() {anim10();}); 
    } 
    else 
    {  
     $("#treest, #treest2, #treest3").click(function() {disabled();}); 
    } 
}); 

Updated Fiddle Demo

回答

0

您可以通過使用off使用拆散點擊功能,或者如果您使用的是舊版本的jQuery使用unbind的是這樣的:

$(window).scroll(function() { 
    if ($(this).scrollTop() < 200) 
    { 
     $("#treest, #treest2, #treest3").click(function() {anim10();}); 
    } 
    else 
    {  
     $("#treest, #treest2, #treest3").off('click')); 
    } 
}); 
+0

沒有,這是不工作...現在動畫開始不在0-200的區域頂端:/爲什麼? – user3191542