I am constantly using the astinus development process. Some JS Code has been pasted in, so an error is displayed on the page. Apparently, I put the source code directly into the html text-Well, after I switched from 05 years to online games, I have never done anything serious about web. So, I need a method escape. I searched the internet and wrote a regular expression replacement for most of them. However, my habit is to respect existing resources. Someone suggested the dom function. Pass it as innerTEXT to a dom object, and then take the innerHTML attribute to get the escaped text.
The method is good, but is there a clever way to write it?
Someone in the JQuery community has provided a solution: if there is a text context, you can perform the escape (x).text(context).html () on a jQuery object $ (x), and then return an escaped text.
As a matter of fact, we can use the text () function to assign values to jQuery objects ......
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.