Reputation: 3712
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?
Upvotes: 2
Views: 797
Reputation: 2598
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 \n
s.
This is far from a perfect solution, but it might be enough for your case.
Upvotes: 1