Created
July 26, 2016 09:03
-
-
Save mehdichaouch/23963995f5e69aef17fe32510d45fb05 to your computer and use it in GitHub Desktop.
Javascript Regex to replace text NOT in html attributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
walk(document.body); | |
setTimeout(function() { | |
walk(document.body); | |
}, 1000); | |
function walk(node) | |
{ | |
// Source: http://is.gd/mwZp7E | |
var child, next; | |
switch ( node.nodeType ) | |
{ | |
case 1: // Element | |
case 9: // Document | |
case 11: // Document fragment | |
child = node.firstChild; | |
while ( child ) | |
{ | |
next = child.nextSibling; | |
walk(child); | |
child = next; | |
} | |
break; | |
case 3: // Text node | |
handleText(node); | |
//imgFind(node); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment