jQuery hover function
- by Daniel Hertz
So I have a hover function that is supposed to move an arrow under the corrent the link that someone hovers over. The problem is, the arrow never returns to the current link when the person stops hovering over the link. However, if I set the left properly with a constant value it works. Anyone have any ideas?
var currentId = '#' + $('body').attr('id') + '_link';
var xCordCurrent = $(currentId).offset().left - ($('#arrow').width() / 2);
var xCordHover = $(event.target).offset().left + ($(event.target).width() / 2) - ($('#arrow').width() / 2);
$('#arrow').animate(
{ left: xCordHover }, {
duration: 'slow',
easing: 'easeOutBack'
})
}, function(event) {
$('#arrow').animate(
{ left: xCordCurrent }, {
duration: 'slow',
easing: 'easeOutBack'
})
});