2012-07-23 3 views

답변

1

이와 비슷한?

$(document).ready(function() { 
    $('#test, .comments').on('mouseenter', function() { 
     $('.comments').stop(true,true).show('slow'); 
    }); 
    $('#test').on('mouseleave', function() { 
     $('.comments').stop(true,true).hide('slow'); 
    }); 
})​;​ 

FIDDLE

도 그냥 단축 할 수 :

$('#test').on('mouseenter mouseleave', function(e) { 
    $('.comments').stop(true,true)[e.type==='mouseenter'?'show':'hide']('slow'); 
}); 

FIDDLE

+0

+1은'bind' 대신'.on()'을 사용한다. :) –