Input Fires Keypress Event Twice

后端 未结 8 2367
小蘑菇
小蘑菇 2021-02-18 14:26

This question has been asked/answered (mostly) before, BUT I\'ve tried three things to stop the event from bubbling but nothing has worked:

return false;
e.stopPr         


        
8条回答
  •  星月不相逢
    2021-02-18 15:10

    Try unbinding the event first then bind it, refer below code:

    $('.addField').show().unbind('keyup').keyup(function(event){
     event.preventDefault();
    
      if(event.keyCode == 13 || event.keyCode==9) {
    ProfilePage.createTag( this, 'nada', 'addField')
        $(this).hide().val('');
    
        return false;       
    }
    

    An explanation is here, i had written a post about this on my new blog.

提交回复
热议问题