Skip to content Skip to sidebar Skip to footer

Find All Elements That Have A Certain Data Attribute (regardless Of Value)

I have a form with a bunch of text elements, some of which have a data attribute set. I want to loop through all the elements that have that attribute, extracting the attribute. I'

Solution 1:

The [data-foo] selector is correct, but you should use it in a filter, instead of in a find:

var datas = textInputs.filter('[data-foo]');

See working fiddle here

Solution 2:

Post a Comment for "Find All Elements That Have A Certain Data Attribute (regardless Of Value)"