How to display double quotes in JavaScript

Viewed 78539

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 what is the way to display a string in double quotes.

One thing I forgot to mention that I want to display the string in input text box.

5 Answers

Whoever is still looking into this should use the following:

In your HTML page/template, use this code (in this case, he wants it for an input)

<input id="name" name="label" type="text" value="<%- label %>"

Notice that I'm using

<%- %>

instead of the classic

<%= =>

That should automatically escape the value you're trying to display and show up in your input without any extra work.

Related