function showSnack(id, texto) { // Get the snackbar DIV var x = $("#"+id); // Add the "show" class to DIV x.addClass("show"); x.html(texto); // After 3 seconds, remove the show class from DIV setTimeout(function(){ x.removeClass("show"); }, 2000); }