Retrieving all attributes of a given element and their values.

Retrieving all attributes of a given element and their values.

jQuery appears to be missing a way to retrieve an array of attribute names for a given element, and to (optionally) retrieve their values at the same time.

riddlemd has created two concise plugins to address this shortcoming - listAttributes and mapAttributes - but I think this functionality should be core, and ideally unified into a single function - perhaps called attrs() - which optionally retrieves a map rather than a list via an optional parameter, set to true for map, false for list... not sure which should be the default though...