Home > Web Front-end > JS Tutorial > body text

js dynamically generates html trigger event parameter character escaping example

高洛峰
Release: 2017-02-17 16:27:34
Original
1396 people have browsed it

The following editor will bring you an example of dynamically generating html using js to trigger event parameter character escaping. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look.

Usually, in the process of using JS to dynamically generate html, corresponding style, event and other attribute elements will be embedded, and at this time, the so-called "single and double quotation marks" often appear. Not enough", don't worry, you can use the escape characters in the html language to solve the problem.

Let’s introduce the corresponding escape characters:

& —— (ampersand) The escape characters correspond to &

“ —— (double quote) double quotation mark, the escape character corresponds to "

' —— (single quote) single quote, the escape character corresponds to '

< —— (less than) less than sign, The escape character corresponds to <

> —— (greater than). The escape character corresponds to >

. For example, in js:

var html = "

Click it

";

The corresponding generated html will be:

Click it

The above example of js dynamically generating html to trigger event parameter character escaping is shared by the editor I’ve given you all the content, I hope it can give you a reference, and I hope you will support the PHP Chinese website.

For more examples of js dynamically generating html and triggering event parameter character escaping, please pay attention to the PHP Chinese website for related articles!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!