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 th
var tab_attribs = $('li.tab_item').map(function () {
return $(this).attr("custom_attribute");
});
This will give you an array of the custom attribute values. Of course, you can do this more traditionally:
var tab_attribs = [];
$('li.tab_item').each(function () {
tab_attribs.push( $(this).attr("custom_attribute") );
});
Anyway, you should probably make use of the data-*
attributes that HTML5 provides:
-
and (see jQuery data()):
$('li.tab_item').data("foo"); // -> "some custom data"