Video of the Day
Assign your function's string parameter to your temporary DIV's "innerHTML" attribute.
Create a temporary string variable in your function.
Grab the plain text content of your temporary DIV using its "textContent" and "innerText" attributes and assign it to your temporary string variable. Because of cross-browser compatibility issues, both "textContent" and "innerText" will be defined in some web browsers and undefined in others, but one or the other will be defined in all versions of all major browsers.
Return the value held by your temporary string using a "return" statement. This will return the plain text value of your converted HTML.
Instead of using IF-THEN statements to check cross-browser compatibility and to decide whether to use “textContent” or “innerText” in your function, simply assign your temporary DIV element’s plain text value to your temporary string variable as follows: var tmpString = tmpDiv.textContent || tmpDiv.innerText.