Jump to content


SplitText: <br> tags and spaces (part 2)

Moderator Tag

Recommended Posts

I stumbled upon another oddity when using splittext on a text with line breaks:

<div class="test1">This results <br>in six words.</div>

results in six words and one linebreak.

<div class="test2">This results  <br>in seven words.</div>

results in seven words (one of which is empty) and what looks like two linebreaks. The difference between test1 and test2 is that the second one has two spaces before the linebreak.


Since a space is normally not treated as a word, this seems like a bug to me. Multiple spaces should be treated the same as a single space.



Demo here:



See the Pen wFkbL by patrickklug (@patrickklug) on CodePen

Link to comment
Share on other sites

Are you sure you're using the latest version? I wasn't able to get it to do six or 7 words in your example. I did find one change I needed to make to SplitText, though. Please snag the latest bonus zip and give it a whirl. 

Link to comment
Share on other sites

Using your example, i only see the following in the console:



I'm not seeing 6 or 7.


Tested in latest Firefox and Chrome on Windows 7 (PC)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.