0

I want to get array of all custom attribute name used in document/element (e.g. data-abc, data-pqr)

Olimpiu POP
  • 5,001
  • 4
  • 34
  • 49
Shridevi
  • 19
  • 7

1 Answers1

2

Use .data() without passing any arguments.

$(element).data();

$( "body" ).data(); // { foo: 52, bar: { myType: "test", count: 40 }, baz: [ 1, 2, 3 ] }

The above gives all the data- attributes found in the tag as well as set by JavaScript.

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252