var animate_parm = {}; if($(object).css("top")=="0px"){ animate_parm['top'] = "-"+settings.split_distance+""; } if($(object).css("left")=="0px"){ animate_parm['top'] = "left":"-"+settings.split_distance+""; } $(object).animate(animate_parm);