Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

$(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!

like image 829
user2097217 Avatar asked Sep 11 '25 04:09

user2097217


1 Answers

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);
});
like image 143
undefined Avatar answered Sep 12 '25 21:09

undefined