javascript - JS | After onkeypress an Onclick event is fired in IE10 -


<button type="submit" id="button" onclick="btnclick()">add</button> <input type="text" id="prefix" placeholder="type" onkeypress="process(event)">  function process(e) { var code = (e.keycode ? e.keycode : e.which); if (code == 13) { alert("input"); } }  function btnclick() { alert("button"); } 

there input box , button. user should able enter data using button or use enter key inside input box.

this works in chrome, ie edge, errors in ie10. in ie10 when user hits enter button, fires inputbox event code, , executes code button well.

jsfiddle

changing type attribute type="button" solved it


Comments