jQuery hover function

Posted by Daniel Hertz on Stack Overflow See other posts from Stack Overflow or by Daniel Hertz
Published on 2010-04-21T08:40:01Z Indexed on 2010/04/21 8:43 UTC
Read the original article Hit count: 371

Filed under:
|

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'
        })
    });

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui