O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making a little duck bounce when clicked

This is arguably useful at best, but, goodness gracious, it is goobly goblets of fun!

Making a little duck bounce when clicked

Getting ready

Position the standing and bouncing versions of our duck, stacked in absolute positioning so that the standing version obscures the bouncing version.

<div id="main">
<div id="duck_it">
<img src="08_duck_bounce.jpg" alt="Ouch!"
title="Ouch!" id="bounce"/>
<img src="08_duck_stand.jpg" alt="Click me!"
title="Click me!" id="stand"/>
</div>
</div>
<style type="text/css">
#main { width:600px; margin:auto; }
#duck_it { margin-top:10px; cursor:pointer; }
#duck_it img { position:absolute; }
</style>

How to do it...

The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required