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.
In JavaScript, single (' ') and double (“ ”) quotes are frequently used for creating a string literal. Generally, there is no difference between using double or single quotes, as both of them represent a string in the end.
For printing double quotes(” “), using print() in C we make use of ” \” ” backslash followed by double quote format specifier.
Example: Print quotes using backslash (\) In this example, we will use the backslash (\) to escape the quotation mark. It's nine o' clock in the morning.
Enclosing Quotation Marks That means strings containing single quotes need to use double quotes and strings containing double quotes need to use single quotes. "It's six o'clock."; 'Remember to say "please" and "thank you."'; Alternatively, you can use a backslash \ to escape the quotation marks.
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
to show double quote you can simple use escape character("\") to show it.
alert("\"Hello\"");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With