function talksAbout(node, string) {
if (node.nodeType == document.ELEMENT_NODE) {
for (var i = 0; i < node.childNodes.length; i++) {
if (talksAbout(node.childNodes[i], string))
return true;
}
return false;
} else if (node.nodeType == document.TEXT_NODE) {
return node.nodeValue.indexOf(string) > -1;
}
}
console.log(talksAbout(document.body, "book"));
Created
January 31, 2018 00:28
-
-
Save RupGautam/e2cdcea1449f42e3c5c56bd73d8d0a5e to your computer and use it in GitHub Desktop.
[Lecture 4] JavaScript
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment