jQuery event triggers twice

后端 未结 3 627
不知归路
不知归路 2021-02-11 04:11

Can someone explain to me why this event triggers twice? It doesn\'t seem to do it on jQuery versions prior to 1.7.



        
3条回答
  •  醉梦人生
    2021-02-11 04:31

    You just need to call it once:

    $('#box').on('blur', function() {
        console.log('This will trigger twice!');
    });
    
    $('#box').blur();
    

    Updated Fiddle

    or just remove your jQuery code and keep your onblur event inside your input tag.

提交回复
热议问题