K. Ayaz K. Ayaz - 2 years ago 82
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?

Answer Source

You can use split() of JavaScript

var text = "Hey There : Part 1";
var newText = text.split(":").join('\n');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download