Because the alert receives focus from your text box, and when you close the alert dialog, the focus returns. If your function has any non-focusing mechanism, it will be launched only once: http://jsfiddle.net/G8CmV/
<input type="text" /> <div id='tester'>Test:</div> $('input[type="text"]').live('focus', function(event) { $('#tester').html( $('#tester').html() + "_*" ); });
source share