2011-08-10 7 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의 hover 이벤트는 2 개의 함수를 취할 수 있습니다. 첫 번째는 마우스 오버, 두 번째는 마우스 아웃입니다. 자세한 정보는 http://api.jquery.com/hover/를 참조하십시오. –

관련 문제