I would like to display messages, and then hide them using the setTimeout
function. So I would like the function I pass to the setTimeout
function to take a parameter, the message to hide, so I can use 1 generic callback function. I tried the below code, but the label
parameter is undefined when the callback executes.
var label = $('.js-a-label');
label.html('the message!');
setTimeout(hideMessage(label), 5000);
function hideMessage(label) {
label.html('');
}