fadein - Jquery .html, then .fadeout -


i trying update .html(''), delay(400) , fadeout, thereafter update .html(''), , fadeinagain...

if(data==1) { var html = "an other text"  $('#nyhedsbrev').html('<br/><p style=\"width:100%; text-align:center;\">tak din tilmelding</p><br/>'); $('#nyhedsbrev').delay(2000).fadeout().html(html).fadein();  } 

it works fine if use line 2 - or if try line one. however, these won't work.

i have tried combine 2 lines - deleting second $('#nyhedsbrev). can explain how can first show new text - fade out replace innner html , fade in?

        • clarify - - - problem first part not show - fade out/in works...

jquery fadein / fadeout (and other animates methods) can take callback second argument.

if(data==1) {      var newhtml = html;     $('#nyhedsbrev').fadeout(500, function() {         $('#nyhedsbrev').html(newhtml).fadein();     }); } 

working example : jsfiddle


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -