小さなブロック内の既存のコンテンツの背後にカラー ブロックをスライドさせようとしています。問題があり、同じページの複数のインスタンスで機能させる必要があります。
どんな助けでも大歓迎です。
小さなブロック内の既存のコンテンツの背後にカラー ブロックをスライドさせようとしています。問題があり、同じページの複数のインスタンスで機能させる必要があります。
どんな助けでも大歓迎です。
mouseenter
とmouseleave
の代わりにmouseover
とを使用しmouseout
ます。
mouseout
カーソルが親 div の別の子要素に入るとトリガーされます。
これは、あなたの望むことですか?
.box2
私は基本的にアニメーション化されているかどうかのチェックを追加します。
$(function() {
$('.container').on('mouseenter', function() {
var box = $(this).find('.box2');
if(box.is(':animated')) return false;
box.stop(true, true).animate({
top: 0
}, 150);
});
$('.container').on('mouseleave', function() {
var box = $(this).find('.box2');
if(box.is(':animated')) return false;
box.stop(true, true).animate({
top: 40
}, 150);
});
});
このようにマウスの休暇を使用します
$('.container')
.mouseover(function (){
$('.box2').stop(true, true).animate({top:0}, 150);
})
.mouseleave(function (){
$('.box2').stop(true, true).animate({top:40}, 150);
})
;
より多くのインスタンスについては、これを試してください
$('.container').each(function() {
var c = $(this);
var box = c.find('.box2');
c.
mouseover(function (){
box.stop(true, true).animate({top:0}, 150);
})
.mouseleave(function (){
box.stop(true, true).animate({top:40}, 150);
});
});