Reputation: 23
I have a series of quotes that look like this:
<p>Being a graphic designer gets you used to rejection of your brilliance. So it’s good practice for dating. </p>
I would like them to look like this:
Being a graphic designer gets you used to rejection of your brilliance. So it's good practice for dating.
I tried using innerHTML, with limited success.
Upvotes: 1
Views: 298
Reputation: 115232
Create a temporary span element with the html content as string using document.createElement
method. Later get the text content by getting the textContent
property.
var str = '<p>Being a graphic designer gets you used to rejection of your brilliance. So it’s good practice for dating. </p>';
// create a span element
var temp = document.createElement('span');
// set the html to the element
temp.innerHTML = str;
// get the text content
console.log(temp.textContent);
Upvotes: 3