Hello everybody! I learn js with “Whith JavaScript for kids” book. Now I reached 10 Chapter: “Interactive programming” and I confused this chunk of a code:
var leftOffSet = 0;
function moveHeading() {
$("#heading").offset({left: leftOffSet});
leftOffSet++;
if (leftOffSet>200){
leftOffset = 0;
}
}
setInterval(moveHeading, 30);
I understand it is very simple, but it does not worck like I read in the book. When you execute this code, you should see the heading element move across the screen until it travels 200 pixels; at that point, it will jump back to the beginning and start again. But not! This does not happen. The element continues to move endlessly.