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

18 Replies, 1005 Views

"Best way to get data attribute javascript values from an element?"

Hey y'all!

So I’ve been messing around with some HTML elements and need to grab those sweet data-* attributes. What’s the *simplest* way to get data attribute javascript values?

I’ve tried `element.dataset.something`, but sometimes it feels like overkill? Or maybe I’m just doing it wrong lol.

Also, is there a modern way to get data attribute javascript without jQuery? Cuz I’m tryna keep things lightweight.

Oh, and if your get data attribute javascript method isn’t working, maybe check for typos? Happens to me all the time smh.

Thanks in advance! 🚀

Messages In This Thread
What's the best way to get data attribute JavaScript values from an element? or How do I properly use - by - 19-06-2024, 03:55 AM



Users browsing this thread: 1 Guest(s)