These days, I asked a question here in SOpt and the guy answered me with a code, creating a function within another function , something simple, but I did not use it, and I started to implement it.
function QuantosEmEstoqueAbrir(){
$j('.availability-only').attr("style", "transform: translate(0);");
function QuantosEmEstoqueFechar(){
$j('.availability-only').attr("style", "transform: translate(300px);");
} setTimeout(QuantosEmEstoqueFechar, 10000);
}
setTimeout(QuantosEmEstoqueAbrir, 10000);
This is a "mini notification" I made for a store system, and it's working fine!
But my question is this, looking at the code mentioned above, which the boy gave me in response:
function domReady(cb) {
(function checkDomReady() {
var state = document.readyState;
if (state == 'loaded' || state == 'complete') cb();
else setTimeout(checkDomReady, 200);
})();
};
He used his function in parentheses. Why this?
(function checkDomReady() {
var state = document.readyState;
if (state == 'loaded' || state == 'complete') cb();
else setTimeout(checkDomReady, 200);
})