Use a.buttonas a selector for a click handler and a source selector to call a function.
EDIT I could not get your code to work independently of the selector with more than one internal DIV. Try this (bonus, it's easier):
$('a.button').click(function()
{
var f = function($this, count)
{
$this.animate({
top: "-=200"
}, 70, function() {
$this.css('top', '220px').animate({
top: "-=220"
}, 70, function() {
if (count > 0) {
f($this, --count);
}
});
});
};
$('#featured li.block div').each( function(i) {
var $this = $(this);
setTimeout( function() {
f( $this, 8 );
}, i*100 );
});
});
source
share