Is it possible to loop through a data()
object?
Suppose this is my code:
$('#mydiv').data('bar','lorem');
$('#mydiv').data('foo','ipsum');
$('#mydiv').data('cam','dolores');
How do I loop through this? Can each()
be used for this?
$.each($.data(this), function(i, e) {
alert('name='+ i + ' value=' +e);
});
This will iterate through each property in 'this' element's data object.