I want to be able to alert the user if the object is at the bottom. What's the mistake i'm doing here?
If its easier to replace the "nummer var" and just check the top style-tag go ahead because it really doesn't matter! :)
Fiddle: http://jsfiddle.net/Bs5Jn/
Code:
<head>
<script src="jquery-2.1.0.min.js"></script>
<style>
#object{position:absolute;
width:100px;
height:100px;
background-color:yellow;}
</style>
</head>
<script>
var nummer = 0;
$(document).keydown(function(e) {
switch (e.which) {
case 38:
$("#object").stop().animate({
top: "10"
});
nummer = 0;
break;
case 40:
$("#object").stop().animate({
top: "200"
});
nummer = 100;
break;
}
})
if (nummer == 100) {
//do something it does have the protected class!
alert("the object is at the bottom");
}
</script>
<body>
<div id="object">
</div>
</body>