JavaScript 2025 · DOM and browser

Read data attributes

Read data-user-id from an element.

const id = element.dataset.userId;

Official JavaScript 2025 documentation

More dom and browser commands

All dom and browser commands · JavaScript 2025 cheatsheet

Was this page helpful?