I use a custom attribute in elements with my own class. I’m trying to return the value of custom attribute for all elements of the class.
I used jQuery to find the elements by class, and jQuery places the object in an array.
var tabs = $('li.tab_item');
Now that I’d have the objects in an array, I would like to return the value for the custom attribute for all the array’s members.
How can this be done?
This will give you an array of the custom attribute values. Of course, you can do this more traditionally:
Anyway, you should probably make use of the
data-*attributes that HTML5 provides:and (see jQuery
data()):