各要素ごとに2つのブール変数を使用できます。要素を入力するとtrueになり、離れるとfalseになります。
そして、両方を偽にして=>要素を非表示にしたときだけです。
$(document).ready(function(){
var bslider = false;
var btest = false;
$('#slider').mouseover(function() {
bslider = true;
$('#slider, #test').stop(true,false).animate(
{'margin-left':'20px'
});
});
$('#test').mouseover(function() {
btest = true;
$('#slider, #test').stop(true,false).animate(
{'margin-left':'20px'
});
});
$('#slider').mouseout(function() {
bslider = false;
if(!bslider && !btest)
{
$('#slider, #test').stop(true,false).animate(
{'margin-left':'0'
});
}
});
$('#test').mouseout(function() {
btest = false;
if(!bslider && !btest)
{
$('#slider, #test').stop(true,false).animate(
{'margin-left':'0'
});
}
});
});
フィドルはもう – diEcho
それを更新働いていない - http://jsfiddle.net/sA5C7/1/ – Andy