简体   繁体   中英

focus() Jquery calls Infinite alerts

 $(document).on('ready page:load', function () { $(document).foundation(); var user_name_input = $('#user_name'); user_name_input.focus(function(){ alert('hi'); }); }); 

When I focus on #user_name I get infinite alerts.

When you do

user_name_input.focus(function(){
        alert('hi');
    });

every time a focus happens on an input, the alert is raised removing the focus.

Once you click Ok for the alert box, the focus for the input box is regained and another alert raised.

Thus, a never ending cycle of alerts and focus

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM