$(function() {
$("#spid").animate({top: '190px' }, 600,'linear' ,function() {
(function spid() {
console.log('Test');
$(this).animate({top:"+=20px"},1000).animate({top:"+=20px"},1000);
setTimeout(spid,2000);
})();
});
});
Существует проблема с this
в приведенном выше коде, фрагмент кода ниже работает нормально
Редактировать :
$(function() {
$("#spid").animate({top: '110px' }, 600,'linear' ,function() {
var cache = $(this);
(function spid() {
cache.animate({top:"+=20px"},1000).animate({top:"-=20px"},1000);
setTimeout(spid,2000);
})();
});
});
Пожалуйста, проверьтекод http://jsbin.com/elaxa3