response stackoverflow

by andres descalzo

HTML

<div></div>
<div></div>
<div></div>

JavaScript

var elements = {}; // <- object
var myformat = function(n) {
    return (String(n).length == 1 ? '0' : '') + n;
}
$('div').each(function(i, el) {
    elements[myformat(i)] = el;
});

console.log(elements);