">
Common definition method
This is the most common definition method, directly defining the JS event on the required object . The relevant transformation is the form of calling the method, as follows
The second one
Here defines the operations that occur when loading and unloading windows.
If it is an event for other objects, you only need to modify the value of the for attribute to the object name and event to the monitored event. As follows:
The third type:
Here we use the registration form , register the method to the specified event of the specified object. Called using the object name.
The complete test code is as follows:
The above is the detailed content of Detailed explanation of how javascript creates event definition examples. For more information, please follow other related articles on the PHP Chinese website!