The jQuery .addclass function is working well to add classes, but they do not come in on a duration:
jQuery(document).ready(function(){
newdiv = $('<div id=\'id".$row_new['ID']."\' style=\"display:none;\" class=\"eventdiv\" data-sort=\"" . $row_new['TimeStamp'] . "\">" . $row_new['Title'] . " TIME: " . $row_new['TimeStamp'] . "</div>');
$('[data-sort=".$after."]').after(newdiv);
$('#id".$row_new['ID']."').slideDown('slow', function() {
$(this).addClass('gradient shadow curved_sml', 5000);
});
});
The code is escaped because it is returned as an object from a php page (through an ajax request) to an html page.
I have tried all different versions of JqueryUI and Jquery, none of them seem to allow it to add a duration to .addclass, the 5000 just becomes a delay.
Currently I have JqueryUI 1.8.9 and Jquery 1.5.2 installed because those versions seem to perform the duration in JSfiddle, but not on my page..
EDIT: I take some of this back… jQuery UI does accept a
durationas the second parameter ofaddClass. jQuery itself does not accept a duration as the second parameter.The second parameter in jQuery UI is how long the effects of adding the class should last for; if you want to delay the addition of the class, then my answer still works.
addClassdoes not accept a delay as the second parameter.If you want the class to be added 5 seconds after the
slideDownhas completed, usesetTimeout:If you want the
slideDownto take 5 seconds, and the class’s to be added immediately: