Can I put delay(500) before an addClass()?

user2097217 picture user2097217 · Mar 16, 2013 · Viewed 41k times · Source
$(document).ready(function(){
    $("#info-text-container").click(function(){
        $("#info-text").delay(500).addClass("info-text-active");
    });   
});

This does not put an delay on it when it gets clicked. Which I want to accomplish. Why and is this hackable, possible to overcome? Thanks!

Answer

undefined picture undefined · Mar 16, 2013

delay only works with animating methods, you can use setTimeout function:

$("#info-text-container").click(function(){
    setTimeout(function(){
       $("#info-text").addClass("info-text-active");
   }, 500);
});