Home > Web Front-end > JS Tutorial > JQuery style HTML text escaping_jquery

JQuery style HTML text escaping_jquery

WBOY
Release: 2016-05-16 18:50:55
Original
803 people have browsed it

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...

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template