如何在JavaScript中编写引号
问题描述:
您好我想做以下事情,但不知道如何写引号
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.
答
两种方式 2次
Two ways times two
-
混合单引号和双引号:
mix single and double quotes:
// single outside, double inside quotes
allSearchResults[0] = '<li><a href="CXS101289/">CXS101289/</a></li>';
或
// double outside, single inside quotes
allSearchResults[0] = "<li><a href='CXS101289/'>CXS101289/</a></li>";
使用一组引号,但可以在一行内跳转:
// double escaped quotes
allSearchResults[0] = "<li><a href=\"CXS101289/\">CXS101289/</a></li>";
或
// 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.