Well, I need a method to escape. After searching online, most of them write a regular replacement by themselves. But my habit is to respect existing resources. Someone suggested that you can use the function of dom. First pass it as innerTEXT to a dom object, and then get the innerHTML attribute to get the escaped text.
The method is good, but in terms of writing, is there any trick?
Someone in the JQuery community came up with a solution: Assuming there is a text context, you can perform $(x).text(context).html() on a jQuery object $(x), and it will return an escaped text.
Actually, I just remembered that in many cases, you can just use the text() function to assign values to jQuery objects...