$(window).on("load", function () { function replacePiping(node) { $(node).contents().each(function() { if (this.nodeType === 3) { // Text var content = this.nodeValue.replace(/\______/g, ""); if (content !== this.nodeValue) { $(this).replaceWith(content); } } else if (this.nodeType === 1) { // Element replacePiping(this); } }); } replacePiping(document.body); });