I have some text in a variable sometext which I want to assign to div using $('div').text(sometext);. The problem is that all <br/>s in sometext turn into < br/ >. I cannot use $('div').html() because there’s a lot of internal structure that I want to retain within the div, so I can only use the .text() function.
So once I’ve passed the text over the to the div, is there any way to change the encoded <br/> tag into a real line break in HTML? I mean something like this:
$('div').convertMyBRsToHTML();
Your requested function should look like this:
Now you could use by: