2012-01-31 2 views
0

現在、オフ()メソッドを使用してホバー状態を無効にしています。 私のアクティブなリンクではないボタンの "on()"でホバーを再度有効にすることはできません。どんな助けでも大歓迎です!!jQuery 1.7のボタンでホバーを使用してon()およびoff()の状態を設定する

$(".datesmenu li").hover(function() { 
     $(this).stop(true, true).animate({ 
      color: "#88bfdc", 
      duration: 200, 
      easing: "easeOutExpo", 
      complete: function() {} 
     }); 
    }, function() { 
     $(this).stop(true, true).animate({ 
      color: "#fff", 
      duration: 200, 
      easing: "easeOutExpo", 
      complete: function() {} 
     }); 
    }); 

     $(".datesmenu li").click(function(){ 

       var index = $(this).prevAll().length; 

       for (var i = 0; i <= index; i++) { 
        if (i==index){ 
         $('#d' + index).stop(true, true).delay(500).fadeIn("fast"), function() {} 
         $(this).off('hover'); 
         $(this).css('color', '#88bfdc'); 
         //$(this).removeAttr('href'); 
        } 
        else{ 
         $(".datesmenu li").not(this).css('color', '#fff'); 
         $(".datesmenu li").not(this).on('hover', function(event) {event.preventDefault();});        
         $('#d' + i).fadeOut("fast"); 
         } 
       } 
    }); 

Idrumgood-私はwork..Iへのソリューションがubind..Howeverを使用するようになってしまった得ることができなかった私は、このメソッドを使用する場合、私は私のrollovers..The色で私のアニメーションにイージングを失います変更内容が、アニメーションは??何らかの理由で削除される。これは、私はそれが仕事を得ることができる唯一の方法だったとして、あなたがより良いとクリーンなソリューションを持っている場合は、私に教えてください...

function init(){ 

    $(".datesmenu li").mouseenter(hoverOn); 
    $(".datesmenu li").mouseleave(hoverOut); 
} 


$(".datesmenu li").click(function() { 

var index = $(this).prevAll().length; 

for (var i = 0; i <= 6; i++) { 
    if (i == index) { 
     $('#d' + index).stop(true, true).delay(500).fadeIn("fast"), function() {} 
     $(this).css('color', '#88bfdc'); 
     $(this).unbind('mouseenter').unbind('mouseleave'); 
    } else { 
     $('#d' + i).hide(); 
     $(".datesmenu li").not(this).mouseenter(hoverOn); 
     $(".datesmenu li").not(this).mouseleave(hoverOut); 
     $(".datesmenu li").not(this).css('color', '#fff'); 

    } 
    } 
}); 

function hoverOn(e) { 
$(e.target).stop(true, true).animate({ 
    color: "#88bfdc", 
    duration: 200, 
    easing: "easeOutExpo", 
    complete: function() {} 
}); 
} 

    function hoverOut(e) { 
    $(e.target).stop(true, true).animate({ 
    color: "#fff", 
    duration: 200, 
    easing: "easeOutExpo", 
    complete: function() {} 
    }); 
    } 

    init(); 
+1

厥。 – ShankarSangoli

答えて

1

ます」ホバーイベントを$(".datesmenu li").not(this).on('hover', function(event) {event.preventDefault();});に戻して、何もするよう指示していません。以前に宣言されたホバーイベントを戻すだけではありません。

ホバーイベントを持ち、それらを関数に入れて、それらをアタッチします。

その後
function hoverOn(e){ 
     $(e.target).stop(true, true).animate({ 
      color: "#88bfdc", 
      duration: 200, 
      easing: "easeOutExpo", 
      complete: function() {} 
     }); 
} 

function hoverOut(e){ 
     $(e.target).stop(true, true).animate({ 
      color: "#fff", 
      duration: 200, 
      easing: "easeOutExpo", 
      complete: function() {} 
     }); 
} 

あなたは上で戻ってそれをバインドしたい:あなたは内部の `click`ハンドラです` hover`ハンドラで任意のコードを持っていないので、

$(".datesmenu li").not(this).on('hover', function(event) {hoverOn(event)}, function(event){hoverOut(event)}); 
+0

私は次のように私のホバー機能を取り除き、イベント「ホバーアウト」とホバーンをバインドしていますか? – user992731

+0

技術的には、最初のホバーバインドをうまくやっています。クリックコードでホバーイベントを再度バインドするときにそれらを再利用する必要があるため、それらを関数に入れます。要点は、それを再バインドするときにホバー機能を明示的に宣言する必要があることです。 – idrumgood

関連する問題