Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
My attempt to find a DOM node using a recursive technique, you have to use a recursive pattern
function findDomNodeById(root, id, result) {
var result = result || [];
// set base case
if ( === id) {
if (root.childNodes.length) {
for (let i = 0; i < root.childNodes.length; i++) {
findDomNodeById(root.childNodes[i], id, result);
return result[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.