Title: *How to find array of properties by data attribute JavaScript – best methods?*
Hey folks!
I’ve been scratching my head over how to find array of properties by data attribute javascript. Like, I need to grab all elements with a specific `data-*` attribute and store their values in an array.
I know `querySelectorAll` is a thing, but is it the *best* way? Or are there faster/more flexible methods? Maybe something with `getAttribute` or `dataset`?
Also, what if I wanna filter them further? Like, only get elements where `data-role="admin"`?
Kinda new to this, so any tips or code snippets would be awesome!
Thanks in advance! 🚀
Hey folks!
I’ve been scratching my head over how to find array of properties by data attribute javascript. Like, I need to grab all elements with a specific `data-*` attribute and store their values in an array.
I know `querySelectorAll` is a thing, but is it the *best* way? Or are there faster/more flexible methods? Maybe something with `getAttribute` or `dataset`?
Also, what if I wanna filter them further? Like, only get elements where `data-role="admin"`?
Kinda new to this, so any tips or code snippets would be awesome!
Thanks in advance! 🚀
