I am attempting to create two animated boxes using jQuery, CSS, and HTML. However, the code is not functioning as expected. The code works fine in a jQuery tutorial app, but when I try it on my own PC, it does not work. Can you help me identify what is wrong with my code?
Here is the code snippet:
<!doctype html>
<html>
<head>
<title>Testing Animation</title>
</head>
<body>
<div class="blueBox"></div>
<div class="redBox"></div>
<style>
.blueBox, .redBox {
width: 100px;
height: 100px;
top: 20px;
position: absolute;
}
.redBox {
left: 20px;
background-color: red;
}
.blueBox {
left: 140px;
background-color: blue;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
var $blueBox = $('div.blueBox');
var $redBox = $('div.redBox');
$blueBox.animate({left: "500px"}, 2000, function(){alert("Animation Completed!");
});
$redBox.animate({width: "0px", height: "0px", opacity: "0"}, 3000);
});
</script>
</body>
</html>
Any guidance or suggestions would be greatly appreciated!