If they are the only class on soaring elements, you can do this:
$('.copyright,.facebook,.twitter,.wordpress').hover( function() { $('.popup-' + this.className).stop().animate({ marginTop: -52 }, 100); }, function() { $('.popup-' + this.className).stop().animate({ marginTop: 0 }, 100); }); $('.copyright').bind('click',false);
or even a little shorter:
$('.copyright,.facebook,.twitter,.wordpress').hover( function(e) { $('.popup-' + this.className).stop().animate({ marginTop: e.type === 'mouseenter' ? -52 : 0 }, 100); }); $('.copyright').bind('click',false);
Note that for .bind('click',false); jQuery 1.4.3 or later is required.
... or better yet, use delegate() (docs) .
$('#footer').delegate('li','hover' function(e) { $('.popup-' + this.className).stop().animate({ marginTop: e.type === 'mouseenter' ? -52 : 0 }, 100); }); $('.copyright').bind('click',false);
source share