如何在JavaScript中编写引号 [英] How to write quotation marks in JavaScript

查看:106
本文介绍了如何在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


  1. 混合单引号和双引号:

  1. 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.

    这篇关于如何在JavaScript中编写引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆