Naughtygirl
Gebruiker
- Lid geworden
- 17 jan 2009
- Berichten
- 174
Ik probeer een div te animeren die, van een top 0 naar bv top 100 gaat. Dit gaat prima, maar hij moet weer terug naar top 0 zodra ik ergens in het document klik. Dit laatste krijg ik niet voor elkaar.
Mijn html:
Mijn CSS:
Mijn jquery:
Kan iemand mij helpen?
Mijn html:
HTML:
<button>Start Animation</button>
<div class="box"></div>
Mijn CSS:
HTML:
button {
position: absolute;
top: 7px;
}
.box {
width: 50px;
height: 50px;
position: absolute;
top: 40px;
background-color: #000;
}
Mijn jquery:
Code:
$(document).ready(function(){
$("button").click(function(){
$(".box").animate({
top: '200px'
});
});
});
Kan iemand mij helpen?