/ Published in: JavaScript

Simple recursive function to find objects that match the value of str hanging anywhere off the global JS object (window).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function findInDOM(str, root, tree) { if(!root) root = window; if(root.length<1) return; for(var i in root) { if(i.indexOf(str) != -1) console.log((tree || "window") + "." + i); if('[object Object]' === Object.prototype.toString.apply(root[i])) findInDOM(str, root[i], (tree || "window") + "." + i); } } findInDOM("get");
Comments
