Skip to content
Advertisement

Tag: enter

Javascript why onClick getting called by enter-key

I’ve got a button with the onClick-event and a textfield with onKeyDown-event. Somehow the button is getting called if I press the enter-key and I don’t know why. Answer When you press Enter in a text field, you trigger a form submission and browsers simulate clicking on the first submit button of the form. You can avoid this by preventing

Advertisement