2 * Utility to get all attributes of an element directy as an object.
4 * @author Timo Tijhof, 2011
6 jQuery
.fn
.getAttrs = function ( all
) {
7 var map
= this[0].attributes
,
12 for ( i
= 0; i
< len
; i
++ ) {
13 // IE6 includes *all* allowed attributes for thew element (including those
14 // not set). Those have values like undefined, null, 0, false, "" or "inherit".
15 // However there may be genuine attributes set to that. If you need them,
16 // set all to true. They are excluded by default.
18 if ( all
|| ( v
&& v
!== 'inherit' ) ) {
19 attrs
[ map
[i
].nodeName
] = v
;