Skip to content

Instantly share code, notes, and snippets.

@jung-han
Created May 2, 2018 09:12
Show Gist options
  • Save jung-han/336d5b4760fa0eccb5b5c38c84382819 to your computer and use it in GitHub Desktop.
Save jung-han/336d5b4760fa0eccb5b5c38c84382819 to your computer and use it in GitHub Desktop.
getNodesHavingClassName: function(nodes, className) {
var i,
tagIndex,
resultNodes = [],
classList = [];
for (i = 0; i < nodes.length; i += 1) {
classList = nodes[i].className;
classList = classList.length === 0 ? [] : classList.split(' ');
if (!Array.prototype.indexOf) {
tagIndex = arrayutil.indexOf(classList, className);
} else {
tagIndex = classList.indexOf(className);
}
if (tagIndex !== -1) {
resultNodes.push(nodes[i]);
}
}
return resultNodes;
},
getNodesHavingId: function(nodes, id) {
return id;
},
getNodesHavingTagName: function(nodes, tagName) {
return tagName;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment