Skip to content

Instantly share code, notes, and snippets.

@tlimpanont
Last active August 29, 2015 14:00
Show Gist options
  • Save tlimpanont/5db82ca6419c5880a067 to your computer and use it in GitHub Desktop.
Save tlimpanont/5db82ca6419c5880a067 to your computer and use it in GitHub Desktop.
find all nodes in DOM with RegExp and delete classNames
var walk_the_DOM = function walk(node, func) {
func(node);
node = node.firstChild;
while (node) {
walk(node, func);
node = node.nextSibling;
}
};
function removeRegExClassesFromDOM(className) {
walk_the_DOM(document.body, function (node) {
if (node.nodeType == 1) {
if (new RegExp(className).exec(node.className)) {
node.className = "";
}
}
});
}
//removeRegExpClassesFromDOM('helloMyName');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment