Why does returning false in the keydown callback does not stop the button click event?

前端 未结 3 1558
离开以前
离开以前 2020-12-01 17:03

I have a button and the following javascript routine.

$(\"button\").keydown( function(key) {
  switch(key.keyCode) {
  case 32: //space
    return false;
  }         


        
3条回答
  •  离开以前
    2020-12-01 17:38

    You can just use one attribute in form to stop submit on enter.

    as like: onkeydown="return false;" in form attribute

     
    

提交回复
热议问题