Jquery select all elements containing the data-id attribute

Asked

Viewed 897 times

0

Hello, I was wondering if there is any way to search all the existing elements on a page containing the attribute data-id just like I can do when I want to get a native HTML tag. for example, if I run the Chrome DOM code $('div') it lists me all the elements existing in the document and that are tag div.

Is there some kind of code similar to $('[data-id=*]')?

1 answer

0

I ended up testing, and found that if the code is executed searching for the attribute without referencing the value of it it returns all the elements that contain that attribute, so: $('[data-id]')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.