Put quotes around a variable string in JavaScript

后端 未结 12 1980
时光说笑
时光说笑 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:09

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

    Whatever your text, to wrap it with ", you need to put them and escape inner ones with \. Above will result in:

    "http://example.com"
    

提交回复
热议问题