Home >Web Front-end >JS Tutorial >js dynamically generates html trigger event parameter character escaping example
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!