Вот код:JQuery добавить класс после FADEOUT укомплектовать сделал
<style>
#box1, #box2, .container { position: absolute; top: 0px;z-index:10; height: 50px; }
#box1 { background-color: #ff0000; width: 100px; left: 200px; }
.container { width: 640px; overflow: hidden; height: 50px; background-color:#000; color:#FFF; }
</style>
<div class="container">
<div id="box1"></div>
</div>
<script>
var animateMe = function(targetElement, speed){
var position = $(targetElement).position();
var positionA = $(targetElement).position();
if(positionA.left = '400px'){
$(targetElement).fadeIn(1000).css({left:'200px'});
};
//animate
$(targetElement).animate(
{
'left': '400px'
},
{
duration: speed,
complete: function(){
animateMe(this, speed);
}
}
).fadeOut(1000);
};
$('.container').hover(function(){
animateMe($('#box1'), 2000);
},
function(){
$('#box1').stop();
});
</script>
То, что я хочу, когда парения:
fadesIn
одушевляет направо
FadesOut (когда fadeOut done сбрасывает левую позицию)
затем снова повторяет номер 1.
Но мой код он сбрасывает postition затем fadesOut, fadesIn ...
ТНХ отлично работает. Оба ответа работают, но код Джаспера, когда ящик мыши все еще невидимый, не исчезает, так что хорошо. – test