HTML onscrollsnapchange Event Attribute
Description
The onscrollsnapchange event attribute runs a script on a scroll snap container when a new snap target has been selected, at the end of a scroll. Use it to update the page once the user has settled on a new slide or section, for example to highlight the matching navigation dot.
The event is a SnapEvent with two properties: snapTargetBlock and snapTargetInline, the elements snapped to in the block and inline directions (or null). It does not fire if the scroll ends at the same snap target it started on. To react while the user is still scrolling, use onscrollsnapchanging.
Syntax
<element onscrollsnapchange="script">
Values
- scriptThe name of the script to use when the event has been triggered.
Example
Browser Support
The following information will show you the current browser support for the HTML onscrollsnapchange event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.
Desktop





Tablets & Mobile





