How-to-remove-unwrapped-text-in-HTML-using-jQuery

How to remove unwrapped text in HTML using jQuery?

In jQuery by hfarazmLeave a Comment

Problem:

In the following HTML, there are unwrapped text or strings i.e  ‘ok‘, ‘sure‘ and  ‘nope‘. I want to delete them from my WordPress site. But since they are not wrapped in any HTML tag separately, when I deleted them using CSS property display: none it hides full td content.  Whats the solution to it? I want to delete only the above-mentioned strings while keeping the input tags in td.

Solution:

Please include this jQuery code in your site. Replace td(line 4) with your html tag that contains the string that you would like to replace. Secondly, replace the ok(line 6) keyword with your string that you would like to replace:

After doing this, you will have strings replaced while html still in place.

Full Code:

Here is complete solution on jsFiddle: