Jump to content
Search Community

SplitText not respecting \n for line breaks

Tagliavia test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

hmmm... I just did a little test. It seems innerText adds the <br> tags for you while innerHTML needs the CSS pre-line. All looks correct until I go to split the text and then the lines don't seem to work on the innerHTML version. I don't know if this is the intended behavior or not. Maybe @GreenSock can offer some more details. Until then, innerText seems to work just fine.

 

See the Pen 90742f069e3137f50676319a4a3517d8 by PointC (@PointC) on CodePen

Link to comment
Share on other sites

  • Solution
9 hours ago, PointC said:

hmmm... I just did a little test. It seems innerText adds the <br> tags for you while innerHTML needs the CSS pre-line. All looks correct until I go to split the text and then the lines don't seem to work on the innerHTML version. I don't know if this is the intended behavior or not. Maybe @GreenSock can offer some more details. Until then, innerText seems to work just fine.

Yes, SplitText isn't intended to support that since there are plenty of line breaks in HTML that shouldn't be interpreted as <br>, but since SplitText does respect <br> tags you can do a simple replace before splitting (if you don't want to use innerText, which is probably the cleanest solution): 

See the Pen 0661f541dfd3eec8c0f9b01c1d902b0f?editors=0010 by GreenSock (@GreenSock) on CodePen

  • Like 1
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.
×
×
  • Create New...