Put quotes around a variable string in JavaScript

后端 未结 12 1979
时光说笑
时光说笑 2020-12-05 02:46

I have a JavaScript variable:

var text = \"http://example.com\"

Text can be multiple links. How can I put \'\' around the variable string?<

12条回答
  •  情书的邮戳
    2020-12-05 03:07

    var text = "\"http://www.example1.com\"; \"http://www.example2.com\"";
    

    Using escape sequence of " (quote), you can achieve this

    You can place singe quote (') inside double quotes without any issues Like this

    var text = "'http://www.ex.com';'http://www.ex2.com'"
    

提交回复
热议问题