adding dynamically add foreach elements as an array

JavaScript
// .each() HAS PARAMETERS.
$('span').each(function (index, element) {
    console.log(element.className + ' ' + element.tagName + ' ' + element.innerHTML);
});
Source

Also in JavaScript: