How to solve the conflict between single quotes and double quotes in javascript _ javascript skills

Source: Internet
Author: User
This article introduces how to solve the single quotation marks and double quotation marks conflict in Javascript. If you need it, you can refer to how to solve the single quotation marks and double quotation marks conflict in Javascript. Think about the following code:

The Code is as follows:


Html + = 'cancel ';


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

The Code is as follows:


Html + = 'cancel ';


An error is reported directly, because the single cited and double cited conflicts here, so I only solve this problem through:

The Code is as follows:


Html + = 'cancel ';


In JavaScript, an error occurs when two double quotation marks are nested.
The following solutions are available:
Replace the inner single quotes'
Replace double quotation marks"
The following is an example.

The Code is as follows:




<BR> JavaScript single quotes and double quotation marks </P> <P>
Script
Function showmSG (S)
{
Alert (S );
}
Script





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.