Search code examples
jquerydelay

delay() for animation in JQuery


I want to create a simple animation using jquery by applying a css class to h1 then removing the class after 100 msec.

Can you please let me know why the below wouldn't work?

$("h1").addClass("pressed").delay(100).removeClass("pressed");


Solution

  • I just realised that the delay() in jquery only works for numerical values. I used pure JS setTimeout() instead and it worked.