Home >Web Front-end >JS Tutorial >How can I use Chrome DevTools to monitor specific events fired on a web page element?
Monitoring Events in Chrome DevTools
You can monitor events fired on any element using Chrome Web Developer by harnessing the powerful monitorEvents function. Here's how:
Invoke monitorEvents: Type the following command into the console:
monitorEvents(<pre class="brush:php;toolbar:false">unmonitorEvents(<pre class="brush:php;toolbar:false">monitorEvents(document.body, 'mouse')))
where $0 represents the selected DOM element.
To stop event monitoring, simply enter the following command:
Alternatively, you can specify an event type as the second parameter to filter monitored events. For instance:
will limit the monitoring to mouse-related events. A list of available event types includes:
The illustrated GIF below demonstrates the usage of the monitorEvents function:
[Image of GIF showing the usage of monitorEvents function]
The above is the detailed content of How can I use Chrome DevTools to monitor specific events fired on a web page element?. For more information, please follow other related articles on the PHP Chinese website!