Hi i'm new to this post and i'm currently studying jquery. I have a jquery book and have been following it's examples to the T. but i've come across a problem when it talks about setinterval. The my coded example simply just doesn't work. I typed it word for word, letter for letter and it simply doesn't work. I've tried it in chrome and explorer, been trying to figure out a solution for some time now please help. Thanks.
Here is the js code:
$(function(){
var $green = $('#green');
greenLeft = $green.offset().right;
});
$(function(){
setInterval(function() {
$green.css('left', ++greenLeft);
}, 200);
});
$(function(){
var $red = $('#red'),
redLeft = $('#red').offset().left;
function moveRed() {
$red.css('left', ++redLeft);
setTimeout(moveRed, 200);
}
moveRed();
});
html code:
<div id="green" class="box">Go!</div>
<div id="red" class="box">Go!</div>
PS. All my plug-ins are there and correct because it works with other example