If I activate the button (with the tab button), and then Enter , the keyboard handler will set fire, and click on the button will generate the event. But the handler Click the call If I delete Some more tests indicate that Then, the problem to resolve: will display this alert and then submit the form Will submit as you expect it. OnClick will submit and the handler will not fire it will just silently post the form. Why?
& lt; Script src = "../js/jquery.js" type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script type = "application / javascript" & gt; $ () Ready (function () {$ ("# F1") .press (function (event) {if (event.keyCode == 13) {var currentInputId = $ (event) [0]. Target.id; Var currentInput = $ ('#' + Current input id); Current input.Click (); Return back;}}); $ ("#F1"). Submit (function () {Alert ("huy"}}}) & Lt; / script & gt; form name = "f1" id = "f1" method = "post" & gt; & gt; input type = "text" & gt; & gt; input type = "submit "Onclick =" return false; "id =" presented ">
rewritten from scratch
button
onclick return
false
onclick = "return false"; , then
keypress handler runs and click on call
button
submit handler is called
submit Handler is not being called * because you come back from
false to
keypress handler.
onclick = "return false"; Remove
false false
questions handler
Comments
Post a Comment