PerformanceEventTiming: target property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The read-only target
property returns the associated event's last target
which is the node onto which the event was last dispatched.
Value
A Node
onto which the event was last dispatched.
Or null
if the Node
is disconnected from the document's DOM or is in the shadow DOM.
Examples
Observing events with a specific last target
The target
property can be used when observing event-timing entries (PerformanceEventTiming
). For example, to log and measure events for a given last target only.
js
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
if (entry.target && entry.target.id === "myNode") {
const delay = entry.processingStart - entry.startTime;
console.log(entry.name, delay);
}
});
});
// Register the observer for events
observer.observe({ type: "event", buffered: true });
Specifications
Specification |
---|
Event Timing API # dom-performanceeventtiming-target |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
target |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.