5
function message (className, text) {
/*Esta variável*/var message = document.getElementById("message");/*Esta variável*/
message.className = className;
message.innerHTML = text;
setTimeout(function () {
message.innerHTML = "";
}, 2000);
}
I will only use this variable within this function, but I believe that if I leave it as a location each time I call this function Javascript will have to access the HTML again to search for this element, and if I leave it as a global element the element will already be caught. What is more performatic?
Thank you very much for the answers, it helped a lot because I didn’t know these ways of doing it, but now I’m going to use.
– user83428