2016-10-27 30 views
0

我試圖讓一個箭頭向上移動,但似乎無法使其工作。
margin-top從180px開始。
這是我到目前爲止的代碼:如何生成動畫箭頭

$(document).ready(function(){ 
setInterval(function(){ 
    $('#pijl').animate({ 
     $(this).css('margin-top', '120px'); 
    },500); 
},6000);}); 

回答

0

嘗試設置你的箭頭在CSS中這樣的位置是:相對的。現在在你的jQuery代碼中使用 試試這個。 callBack函數將動畫無限循環中的箭頭..使用setInterval。

$(document).ready(function() { 
function animated() { 
    $('div.animated-arrow').animate({top: '50px'},500).animate({top: '120px'},500,animated); 
} 

animated(); 

});

希望它能幫助你。