Is is possible to select specific text string on the page directly without a id, class, etc...
I have this text string "ERROR: AffiliateID invalid" that I would like to remove from the page.
Is it possible?
This should solve the problem imho:
document.body.innerHTML = document.body.innerHTML.replace( /ERROR: AffiliateID invalid/g, "");
The code replaces all occurences of the string with empty string.
EDIT: Use it only if you're 100 percent positive that it won't break your HTML in any way.
EDIT 2:
I don't know about a specific jQuery function for this. I found this tip:
1) http://johannburkard.de/blog/programming/javascript/6-quick-jquery-tips-text-manipulation-timers-and-elements.html
Remove a word with jQuery
The simple way – using regular expressions:
var el = $('#id'); el.html(el.html().replace(/word/ig, ""));
The example uses the same replace function as the version in pure javascript. The function comes from JavaScript 1.2 (the standard that is 10 years old and is implemented in all major browsers). So I guess there's no reason to use a function from jQuery.
2) There is a plugin for replacing text in specified HTML tags. Maybe it is worth trying.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With