jQuery event triggers twice

后端 未结 3 1036
抹茶落季
抹茶落季 2021-02-11 04:05

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:27

    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.

提交回复
热议问题