I cannot find a solution to an animation to make a div bounce, using just jQuery animations. Something like does not work:
$("#bounce").click(function() {
$(this).effect("bounce", {
times: 3
}, 300);
});.
I would prefer not to use jQuery UI or any external plugin, such as the easing one. A wobble effect would be just as good in my case, so either will do.
Here is an example, any help would be much appreciated! Thanks in advance
You could simply chain together some
animate
calls on the element like so:Working example: http://jsfiddle.net/Willyham/AY5aL/
Use this function for damped bounces. Be sure to give the bouncing element a unique class if using the code without changes.
I usually use jQuery animate. For your specific question, it could look like this:
The HTML:
The CSS:
And finally, the jQuery:
And here is a working fiddle: http://jsfiddle.net/5xz29fet/1/
For a vertical bounce you can try something like this:
I use this simple plugin, jQuery-Shake, to shake or bounce an element without jQuery-UI.
Fiddle: https://jsfiddle.net/ek7swb6y/3/