I'm trying to use $.trim() to trim whitespace in empty elements so I can check the length of an element to see if it has text content in it and if it does not then remove it from the DOM.
Some elements are returning a length of greater than 0 because they have spaces and/or carriage returns in them which is all that is contained in them.
I basically need to find and remove any empty tags when they have nothing in them.
I don't suppose anyone knows of a simple quick way to just check for and remove any empty tags in the main content of a page, whether they contain any whitespace chars or not by any chance? I'm sure there must be a way.
trim()on the tag's content and it returns an empty string, then no content is in the tag and it can be removed.