why setTimeOut in this code doesn't work ? im tring to show submenus one by one , im not sure if the way is good , someone told me there is a problem in the closure
the code :
function changestyle(){
var els = document.getElementsByClassName("submenu");
for(var i = 0; i < els.length-1; i++)
{
const showone = function(){
els[i].style.display = 'block';
};
const hideone = function(){
els[i].style.display = 'none';
};
setTimeout(showone, 2000);
setTimeout(hideone, 2000);
}
}