var getElementsByClassName = function(className) { const myNodes = []; function innerFn(node) { if (node.classList && node.classList.value.indexOf(className) > -1) { myNodes.push(node) } node.childNodes.forEach((child) => innerFn(child)) } innerFn(document.body) return myNodes; };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter