Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- document.getElementById("submit").addEventListener('click', function(){
- walk(document.body, /\by\/n\b|\(y\/n\)/ig, document.getElementById("inputTxt").value);
- });
- function walk(node, v, p){
- 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, v, p);
- child = next;
- }
- break;
- case 3: // Text node
- handleText(node, v, p);
- break;
- }
- }
- function handleText(textNode, val, p){
- var v = textNode.nodeValue;
- v = v.replace(val, p);
- textNode.nodeValue = v;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment