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
  • 27,643
  • 59
  • 181
  • 333

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
  • 354,903
  • 100
  • 647
  • 710