Google chrome causing infinite loop on textbox focus

前端 未结 5 1145
孤街浪徒
孤街浪徒 2021-01-18 05:39

I\'m getting some strange happenings on google chrome. With the following code I\'m getting an infinite number of alerts.

<

5条回答
  •  醉话见心
    2021-01-18 06:26

    Because alert is getting the focus from your text box, and on closing the alert dialog,focus gets back. If you do any non focusing mechanism inside your function , it will trigger only once : http://jsfiddle.net/G8CmV/

    
    
    Test:
    $('input[type="text"]').live('focus', function(event) { $('#tester').html( $('#tester').html() + "_*" ); });

提交回复
热议问题