2011-08-10 12 views
-1

タグのjQueryカラーホバー効果を取得しようとしています。このjsFiddleでは正しく動作していないことがあります。また、どのように私はそれに緩和効果を得るだろうか?ありがとうございました。jQuery。hover effect 'color'が正しく動作しない

$(document).ready(function() { 
var origColor = $("#links-top-contact").children('a').css("color"); 
    $("links-top-contact").children('a').hover(function() { 
     $(this).css('color' , 'blue'); 
      $("links-top-contact").children('a').hover(function() { 
       $(this).css(origColor); 
      }); 
     }); 
    }); 

答えて

3
$(document).ready(function() { 
    var origColor = $("#links-top-contact a").css("color"); 
    $("#links-top-contact a").hover(function() { 
     $(this).css({color:'blue'}); 
    },function() { 
     $(this).css({color:origColor}); 
    }); 
}); 

更新フィドル http://jsfiddle.net/uHYVf/

+0

恐ろしいはあなたに感謝します!ちょっと不思議なことに、$(this).css({color: 'blue'}); -------------------->}、<------ここに。私はその構文を見て、それはちょうど場所外のように見える。 – Graham

+1

jQueryのホバーイベントには2つの機能があります。最初はマウスオーバー、2番目はマウスアウトです。詳細はこちらhttp://api.jquery.com/hover/ –

関連する問題