In the project, JS is used to display data at the front-end. If you encounter a problem or solution, you can think about the solution.
The background transmits data to JS. js stores the obtained data in the title of the IMG tag. The problem arises, and the background data has a special character & xxxx; ("·"), in this way, the title is displayed as a character.
1. as a result, I began to search for how to use js to convert & xxxx; To "·". I found a lot of articles and did not write well. I wrote my own JavaScript escape functions to escape them, this problem is not so complicated.
2. I started to think about jquery's good method. I couldn't find it, so I gave up.
3.when the HTML text is displayed, it will be automatically escaped as the display character. So let the HTML itself turn it for me and then get the content soon? Therefore, jquery is used to fill in the HTML method of the tag with the string to be escaped, and then extract it. The obtained string has been escaped.
Summary:
Be good at solving problems with existing things and find the simplest method.
This article from the "harder, luckier" blog, please be sure to keep this source http://actor.blog.51cto.com/1764681/1440434
Solution: standing on the shoulders of giants