Over a million developers have joined DZone.

Using Map On An Array Of Elements

·
I wanted to use prototype's map function on a listing of elements like:

document.getElementsByTagName('div').map(function(el) {});

Object.extend(String.prototype, {
  tags_in: function(el) {
    nodes = [];
    elems = $(el).getElementsByTagName(this);
    for(var i = 0; i < elems.length; i++)
      nodes.push(elems[i]);
    return nodes;
  }
});

'div'.tags_in(document).map(function(el) {});
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}