How to display double quotes in JavaScript

后端 未结 4 1057
广开言路
广开言路 2020-12-25 15:06

On html page if I give name in double quotes then it is not getting reflected on page. It displays a blank string. I tried with escape() function but that didn\'t work. So w

4条回答
  •  感动是毒
    2020-12-25 15:27

    You have several options:

    var str = 'My "String"'; //use single quotes for your string
    var str = "My \"String\""; //escape your doublequotes
    var str = "My "String""; //use it as html special chars
    

提交回复
热议问题