title title...."; var str = div1.innerHTML; // &"/> title title...."; var str = div1.innerHTML; // &">
Home >Web Front-end >HTML Tutorial >HTML text escaping tips_HTML/Xhtml_Web page production
Today I saw a little trick for escaping HTML text on CSDN, which is very simple.
1. Use the dom function. Pass it to a DOM object as innerTEXT first, and then get the innerHTML attribute to get the escaped text.
For example:
div1.innerText = "