I want to make script to loop infinity so image will rotate everytime. This is my script which dont work:
function w_gore() {
if(document.getElementById('mycarousel').style.top != '-544px' && document.getElementById('up').align == 'left') {
document.getElementById('up').align = 'right';
$("#mycarousel").animate({"top": "-=136px"}, "slow", function() {
document.getElementById('up').align = 'left';
}, setTimeout(function() {ruch();},1000));
}
}
function ruch() {
w_gore();
}
$(document).ready(function(){
ruch();
});
You’re already using jQuery, but not properly. Here are a few shortcuts:
should be:
document.getElementById('up').alignbecomes$('#up').css('align')document.getElementById('up').align = 'right'becomes$('#up').css('align','right')You also need what Samich suggests.