I want to put all attributes in a Html element into an array: like i have a jQuery Object, whichs html looks like this:
.slice
to convert the attributes
property to ArrayThe attributes
property of DOM nodes is a NamedNodeMap, which is an Array-like object.
An Array-like object is an object which has a length
property and whose property names are enumerated, but otherwise has its own methods and does not inherit from Array.prototype
The slice method can be used to convert Array-like objects to a new Array.
var elem = document.querySelector('[name=test]'),
attrs = Array.prototype.slice.call(elem.attributes);
console.log(attrs);
See console.