Another way to make objects in Javascript
using JQuery
, getting data from the dom and pass it to the object Box and, for example, store them in an array of Boxes, could be:
var box = {}; // my object
var boxes = []; // my array
$('div.test').each(function (index, value) {
color = $('p', this).attr('color');
box = {
_color: color // being _color a property of `box`
}
boxes.push(box);
});
Hope it helps!