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.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.