Code
setTimeout($templateElement.hide(),2000);
executes $templateElement.hide() immediately and passes its return value (jQuery object) to setTimeout . Did you mean:
setTimeout(function() { $templateElement.hide(); }, 2000);
... which passes the reference to the function in setTimeout , which will be called after two seconds. This function then performs hide on invocation.
source share