DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Using Map On An Array Of Elements
I wanted to use <a href="http://project.ioni.st/post/245#post-245">prototype's map function</a> 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) {});





Comments
Snippets Manager replied on Mon, 2012/05/07 - 2:15pm
Snippets Manager replied on Mon, 2012/05/07 - 2:15pm