WKx
WKx

Reputation: 411

.data( ) jquery

Is it possible to get the number of data stored on an element an then iterate through them ?

For example i would like to do something like :

for(;elmt.data().length<i++;){
   //iterate thro elmt.data
}

Upvotes: 2

Views: 119

Answers (1)

lrsjng
lrsjng

Reputation: 2625

.data() returns an object that has no attribute length, but this will work:

$.each($('#someElement').data(), function (key, value) {
    console.log(key,value);
});

Upvotes: 4

Related Questions