Return to Snippet

Revision: 51115
at September 15, 2011 00:15 by richt


Initial Code
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");

Initial URL


Initial Description
Simple recursive function to find objects that match the value of str hanging anywhere off the global JS object (window).

Initial Title
Search for objects attached to the global JS object

Initial Tags
search, DOM

Initial Language
JavaScript