When a user performs a certain action (typing) I run a function that applies a specific styling to that user in a list of 100s of users. As the user continues to type this funct
Need to see some code to be sure, but it seems you could use setTimeout()
(see reference here) with each function call, clearing the old timeout with clearTimeout()
(see reference here) at the beginning of the function.
Use JavaScript's setTimeout()
method to invoke a method to remove the styling after 3 seconds (3000 ms). See below:
var timeout;
function clearStyling() {
// clear your styling here
};
$("#typingBox").on("keypress", function() {
clearTimeout(timeout);
timeout = setTimeout(clearStyling, 3000);
// do your styling here ...
});