如何在JavaScript中写引号?

时间:2022-02-04 06:19:29

Hi I want to do the following, but don't know how to write the quotation marks

你好,我想做下面的事情,但是不知道怎么写引号

allSearchResults[0]="<li><a href="CXS101289/"> CXS101289/</a></li>";

It shall be quotation marks where the currently are.

在当前的位置应该是引号。

4 个解决方案

#1


14  

Two ways times two

  1. mix single and double quotes:

    混合单引号和双引号:

    // single outside, double inside quotes
    allSearchResults[0] = '<li><a href="CXS101289/">CXS101289/</a></li>';
    

    or

    // double outside, single inside quotes
    allSearchResults[0] = "<li><a href='CXS101289/'>CXS101289/</a></li>";
    
  2. use one set of quotes but escape inside ones:

    使用一组引号,但在其中转义:

    // double escaped quotes
    allSearchResults[0] = "<li><a href=\"CXS101289/\">CXS101289/</a></li>";
    

    or

    // single escaped quotes
    allSearchResults[0] = '<li><a href=\'CXS101289/\'>CXS101289/</a></li>';
    

First approach with mixing is usually easier, because it presents less work since you only have to change the opening and closing quote.

混合的第一种方法通常更容易,因为它提供的工作更少,因为您只需更改开头和结尾的报价。

#2


0  

Just escape the quotes inside the a tag.

只需转义a标记中的引号即可。

allSearchResults[0]="<li><a href=\"CXS101289/\"> CXS101289/</a></li>";

#3


0  

you can escape them like:

你可以像:

allSearchResults[0]="<li><a href=\"CXS101289/\"> CXS101289/</a></li>";

or use the other quotes :

或使用其他引号:

allSearchResults[0]="<li><a href='CXS101289/'> CXS101289/</a></li>";

#4


0  

allSearchResults[0]="<li><a href='CXS101289/'> CXS101289/</a></li>";

or

allSearchResults[0]='<li><a href="CXS101289/"> CXS101289/</a></li>';

or

allSearchResults[0]="<li><a href=\"CXS101289/\"> CXS101289/</a></li>";

#1


14  

Two ways times two

  1. mix single and double quotes:

    混合单引号和双引号:

    // single outside, double inside quotes
    allSearchResults[0] = '<li><a href="CXS101289/">CXS101289/</a></li>';
    

    or

    // double outside, single inside quotes
    allSearchResults[0] = "<li><a href='CXS101289/'>CXS101289/</a></li>";
    
  2. use one set of quotes but escape inside ones:

    使用一组引号,但在其中转义:

    // double escaped quotes
    allSearchResults[0] = "<li><a href=\"CXS101289/\">CXS101289/</a></li>";
    

    or

    // single escaped quotes
    allSearchResults[0] = '<li><a href=\'CXS101289/\'>CXS101289/</a></li>';
    

First approach with mixing is usually easier, because it presents less work since you only have to change the opening and closing quote.

混合的第一种方法通常更容易,因为它提供的工作更少,因为您只需更改开头和结尾的报价。

#2


0  

Just escape the quotes inside the a tag.

只需转义a标记中的引号即可。

allSearchResults[0]="<li><a href=\"CXS101289/\"> CXS101289/</a></li>";

#3


0  

you can escape them like:

你可以像:

allSearchResults[0]="<li><a href=\"CXS101289/\"> CXS101289/</a></li>";

or use the other quotes :

或使用其他引号:

allSearchResults[0]="<li><a href='CXS101289/'> CXS101289/</a></li>";

#4


0  

allSearchResults[0]="<li><a href='CXS101289/'> CXS101289/</a></li>";

or

allSearchResults[0]='<li><a href="CXS101289/"> CXS101289/</a></li>';

or

allSearchResults[0]="<li><a href=\"CXS101289/\"> CXS101289/</a></li>";