Home > Web Front-end > JS Tutorial > Solution to the conflict between single quotes and double quotes in js_javascript skills

Solution to the conflict between single quotes and double quotes in js_javascript skills

WBOY
Release: 2016-05-16 17:20:46
Original
1303 people have browsed it

How to solve the conflict between single and double quotes in js, think of the following code:

Copy the code The code is as follows:

html = ' Cancel';

This is the code in js. If it is written like this, a js error will be prompted because the parameters in the removeOpenCss method do not have single or double quotes. If it is written like this here:

Copy code The code is as follows:

html = ' Cancel';

An error will be reported directly because single quotes and double quotes conflict here, so I The only solution is this:

Copy code The code is as follows:

html = ' Cancel';

In JS, an error usually occurs when two layers of double quotes are nested
The following method can be used to solve the problem
Replace the inner single quotes with '
Replace the double quotes with "
As shown in the following example
Copy Code The code is as follows:



<br>JS single quote double quote problem <p>
<script><br>function showmSG(S)<br>{ <br>alert(S);<br>}<br></script>






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