JQuery Slide Div在悬停的悬停在左右



我想修复此jQuery在悬停的div:http://jsfiddle.net/pxljg

html:

<div class="holdingbox">
<span class="rightbox">
    <span class="content">Kenyér</span>
</span>
<span class="leftbox">></span>

jQuery:

$('.holdingbox').hover(function(){
    $('.rightbox').animate({width: '90px'}, 1000)
}, function(){
    $('.rightbox').animate({width: '-0'}, 1000)
});

CSS:

div {
    display : inline-block;
}
.holdingbox {
    position: relative;
    top: 0;
    margin-left: 100px;
}
.leftbox {
    position: relative;
    top: 0;
    left: 0;
    display: inline-block;
    font-size: 24px;
    background-color: #ac193d;
    color: #FFF;
    font-weight: bold;
    padding: 1px;
}
.rightbox {
    position: relative;
    display: inline-block;
    overflow: hidden;
    width: 0;
    height: 30px;
    vertical-align: top;
    margin-right: 0;
}
.content{
    width: 100px;
    position: absolute;
    background-color: #ac193d;
    height: 29px;
    left: 0;
    top: 0;
    right: 0;
    color: #FFF;
    padding-left: 5px;
}

例如:http://www.jamieoliver.com/-> slider上一个悬停的下一个箭头(我需要!!)

我的问题是当我试图悬停在">"(箭头)上时,它是从左到右滑动的。但是,当我一遍又一遍地徘徊时,当动画滑到'宽度:0'时,我将鼠标从动画中留下,不要停止,然后仍然向左徘徊在x times x时,我徘徊在Div上。谁能解决这个问题,我该如何解决此问题?

p.s。:我猜这个问题可以通过.stop()函数解决。如何?

您可以使用.stop()停止当前动画:http://jsfiddle.net/pxljg/2/

$('.rightbox').stop().animate({width: '-0'}, 1000)

最新更新