I have been trying to create a simple practice page using jQuery's animate() to animate some divs on button presses, but it doesn't work. I have been getting an uncaught syntax error on line 29, $(.red).animate
... Why does this happen?
<!DOCTYPE html>
<html>
<head>
<title>ANIMATE WITH JQUERY</title>
<meta charset = "utf8">
<link rel = "stylesheet" href = "anim.css">
<script src = "jq/jquery-1.10.2.js"></script>
</head>
<body>
<button id = "but1">animate 1</button>
<button id = "but2">animate 2</button>
<div class = "red"></div>
<div class = "red"></div>
<div class = "red"></div>
<div id = "blue"></div>
<div id = "grey"></div>
<script>
$(document).ready(function() {
$('#but1').click(animateOne);
$('#but2').click(animateTwo);
});
function animateOne() {
$('.red').animate({margin-left:"200"},{duration:2000});
$('#blue').animate({margin-top:"30"},{duration:1000});
$('#grey').animate({margin-bottom:"200"},{duration:1500});
}
function animateTwo() {
$('.red').animate({margin-left:"400"},{duration:2000});
$('.red').animate({opacity:"0.2"},{duration:3000});
$('#blue').animate({margin-top:"30"},{duration:1000});
$('#grey').animate({margin-bottom:"200"},{duration:1500px});
}
</script>
</body>
</html>