Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using Map On An Array Of Elements

DZone's Guide to

Using Map On An Array Of Elements

·
Free Resource
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:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}