javascript - setTimeout function doesnt stop execution? -
i have stumbled upon problem settimeout.
$current.removeclass(class2); settimeout(function(){$current.css('display', 'none')},1000); if(!$current.is('#' + id)){ $('#' + id).css('display','block'); settimeout(function(){$('#' + id).addclass(class2)}, 1000); $current = $('#' + id); }
i want if statement executed after add together css "display:none". how can accomplish this? thought settimeout stop execution of code , go on after function has run.
you set code within function within timeout (code spacing of import well...):
$current.removeclass(class2); settimeout(function() { $current.css('display', 'none') if( !$current.is('#' + id) ) { $('#' + id).css('display','block'); settimeout(function() { $('#' + id).addclass(class2) }, 1000); $current = $('#' + id); } },1000);
javascript jquery
No comments:
Post a Comment