javascript - why browser trigger a click event instead of a submit in a form? -
i have code http://jsfiddle.net/2gay9/3/
html
<form action="/" method="get" onsubmit="return false";> test: <input type="text" value=""> <input type="submit" value="submit"> </form>
js
jquery('input').bind("keydown click", function(event){ console.log(event.type); console.log(jquery(this)); });
try hit return in input text , console:
keydown jquery(input) click jquery(input submit)
question: why browser triggering 'click' event on submit button, instead of trigger 'submit' event in form? project flaw or specification? how can cancel second event without cancel form submission?
tks
update in other words, need diferenciate event browser event.
use:
jquery('input').bind("keydown click", function(event){ event.preventdefault(); console.log(event.type); console.log(jquery(this)); });
Comments
Post a Comment