Is there a shortcut function that converts a DOM element and its various attribute/value pairs to a corresponding Javascript object?
E.g convert this in the HTML page:
<div id="snack" type="apple" color="red" size="large" quantity=3></div>
to an object in Javascript, as if you had typed:
var obj = {
id: "snack"
type: "apple"
color: "red"
size: "large"
quantity: 3
};
Not really a shortcut but at least a short implementation that does what you want: