$(document).ready(function(){
var el = $("#box");
animate(el,300,function(){
});
});
function animate(el,leftVal,callback){
el.animate({
left : leftVal
},{
duration : 2000,
queue : false,
easing : "swing",
complete : function(){
//alert("finished");
if(callback){
callback();
}
}
});
}
$(document).ready(function(){ var el = $(#box); animate(el,300,function(){ }); }); function animate(el,leftVal,callback){ el.animate({ left : leftVal
Share
Add a
durationparameter to your function:Then call the parameter in the duration part of the function:
When you’re calling the function, define the last parameter (which is now the duration):