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
Use .map()
:
$("li.tab_item").map(function (){
return this.getAttribute("myAttribute");
});
That gives you an Array of values wrapped in a jQuery object. If you want to get the Array, call .get()
, ie .map(...).get()
.
By the way, you can also select the elements by attribute instead of class:
$("[myAttribute]")
This will return all elements on the page that have a myAttribute
attribute.