Home>Article>Web Front-end> Is there a click event in JavaScript?
There is a click event in JavaScript; you can use onclick to bind the click event. The syntax is "
" or "object.onclick=function(){To Executed JavaScript};".
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
Is there a click event in JavaScript
HTML events can be browser behaviors or user behaviors.
The following are examples of HTML events:
HTML page finishes loading HTML input field changes HTML button is clicked
Usually, when an event occurs, you can do something .
JavaScript can execute some code when the event is triggered.
The onclick event occurs when an element is clicked.
Syntax
In HTML:
In JavaScript:
object.onclick=function(){SomeJavaScriptCode};
Parameter Description
SomeJavaScriptCode Required. Specifies the JavaScript to be executed when this event occurs.
The example is as follows:
123 单击按钮触发函数。
Output result:
The above is the detailed content of Is there a click event in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!