Skip to content
Advertisement

How to stop JS code from wrapping white spaces into a span?

I found JS code from “Detect browser wrapped lines via javascript” but it will wrap white-spaces into a span. I’m using this code on a WordPress site and I cannot reciprocate the problem anywhere else. I tried to sanitize the code but that didn’t work as well.

Is there a way to check if a span is blank and remove the span?

JavaScript
JavaScript

Advertisement

Answer

You can check if the content that’s being wrapped is not empty.

JavaScript

Here’s the edited snippet:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement