How to find array of properties by data attribute JavaScript – best methods? or What’s the easiest wa

16 Replies, 1574 Views

If you’re using jQuery (I know, I know), this is stupid easy:

```javascript
const admins = $('[data-role="admin"]').toArray();
```

But yeah, vanilla JS with querySelectorAll is the way to go if you’re not already using jQuery.

Messages In This Thread



Users browsing this thread: 1 Guest(s)