I want to get text from elements on a page. I don’t want the html tags but I want the linebreaks. If I do a $('#element').text() the linebreaks are removed. What is the way to keep the paragraphs from the element without the html tags?
I want to get text from elements on a page. I don’t want the
Share
A quick and dirty solution would be to extract the HTML, replace all
<p>,</p>and<br>tags with certain strings, then transform the HTML into text using jQuery’s.text, then replace those certain strings with\ns.This is far from a perfect solution, but it might be enough for your case.