data-attributes
Extract data attributes from a DOM node.
Follows the data-*
spec.
Install
Via npm:
$ npm install data-attributes --save
Via Bower:
$ bower install data-attributes --save
Usage
Click me
API
dataAttributes(element)
Returns an object containing all data attributes (with camel case keys) from a given DOM node.
Motivation
I needed something like jQuery's $.data()
to simply retrieve data attributes from DOM elements. It was for a very old project that needs to support IE7.
If you do not care about IE7, you can simply use dataset
.
License
MIT © Rafael Rinaldi