by @kodeazy
JQuery How to disable a text after n seconds of click?
- To disable a Text after specified number of seconds we use
setTimeOut
function. -
Below is the syntax to disable after 2 seconds.
setTimeout(function(){ $("#demo").css("display", "none") }, 2000);
-
Below is the Example to disable the text after 2 seconds.
<!DOCTYPE html> <html> <body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <p id="demo"> Click to disable after 2 seconds</p> <script> $("#demo").click(function(){ setTimeout(function(){ $("#demo").css("display", "none") }, 2000); }); </script> </body> </html>