The question is actually quite simple. How do I make the div's content change before the alert shows up?
JSFiddle:
https://jsfiddle.net/n2n5drL2/1/
HTML:
<div id="test">
Some Text
</div>
<button id="change">
change
</button>
JavaScript:
$('#change').click(function(){
$('#test').text('new content');
alert('how to make this alert shows after the div changes its content?')
})
See Question&Answers more detail:os