javascript - unable to understand the logic of settimeout in this peice of code -


i have hide of subsections on click on button , here code

 $('#mybutton').on('click', function (event){     event.preventdefault();     $('#panel').hide();     $('#header').hide();     settimeout(function(){ $('#sub-section').attr('style','display:none;'); }, 100); }); 

at last statements if remove function set timeout display attribute none not set on #sub-section . came know , actual need of settimeout here. shold work without settimeout also.

if function hide taking time execute , have tried

$('#panel').attr('style','display:none;'); $('#header').attr('style','display:none;'); $('#sub-section').attr('style','display:none;'); 

also not working. @ 3rd statement only.

in case display: none applied element after 100 milliseconds. i think done because above have called hide function 2 times , function work animation take time. hide function finish in approximately less or equal 100 milliseconds display: none applied


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -