Jcfg.J Jcfg.J - 1 month ago 22
HTML Question

Insert line break into string

I know this a repeat question, but I tried a lot of things and none of them worked. Essentially, I have:

var med = word.replace("!", '<br />');
(div.get(0)).textContent = med;

Side note: the div has a
inside of it and that is what I am changing. Thank you for any advice in advance!


I can't see the whole of your code so I'm not sure what your HTML looks like. Try this code:

var str = jQuery('p').html();
str = str.replace('!', '<br />');

There is a jsFiddle here: https://jsfiddle.net/pavkr/bq8be893/

You could simplify the code but this is basically just to show you how it works.