3

I'm trying to understand a jquery script which stores an object using jquery data().

Is there an easy way to retrieve all information stored? Especially since I don't know all of the keys that have been used.

Thanks for help!

frequent
  • 26,445
  • 56
  • 171
  • 325

1 Answers1

3

If you call .data() with no arguments, it returns what you want.

var allData = $('some-element-selector').data();
for (var k in allData)
{
    if (allData.hasOwnProperty(k))
    {
        console.log(k + ':' + allData[k]);
    }
}
Matt Ball
  • 344,413
  • 96
  • 627
  • 693