Name
Input.onclick: event handler invoked when a form element is clicked — DOM Level 2 Events
Synopsis
Function onclick
Description
The onclick property of an
Input object specifies an event-handler function that is invoked
when the user activates the input element. This is typically done by
clicking the element with the mouse, but the onclick handler is also triggered when the
user activates the element using keyboard traversal. The onclick handler is also invoked when the
click( ) method is called for the
element.
Note that the input elements of type “reset” and “submit”
perform a default action when clicked: they reset and submit,
respectively, the form that contains them. You can use the onclick event handlers of each element to
perform actions in addition to these default actions. You can also
prevent these default actions by returning false or by using the other
event-cancellation techniques described in Chapter 17. Note that you can do similar things
with the onsubmit and onreset event handlers of the Form object
itself.
See Also
Element.addEventListener(
); Chapter 17
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access