K. Ayaz K. Ayaz - 1 year ago 28
CSS Question

How to separate a line into two after ":" by using javascript?

I have a blog and blog titles are like this;

"Hey There: Part 1"

So, is there any chance to break the line after ":", because I want Part 1 to start a new line. So it should be like this:

"Hey there:

Part 1"

But there are so many titles, so I want to do this with a javascript code to all of those titles. Is this possible?


You can use split() of JavaScript

var text = "Hey There : Part 1";
var newText = text.split(":").join('\n');