What's the best way to get data attribute JavaScript values from an element? or How do I properly use

18 Replies, 1251 Views

Yo, `dataset` is the way to go for sure! But if you wanna keep it old-school, `getAttribute()` works too.

Pro tip: if you're debugging, just `console.log(element.dataset)` to see all the data attributes at once. Saves time!

Also, MDN has a great doc on get data attribute javascript stuff: https://developer.mozilla.org/en-US/docs...nt/dataset

Messages In This Thread



Users browsing this thread: 1 Guest(s)