We help IT Professionals succeed at work.

How to include double quote on alert?

Whing Dela Cruz
on
Hi! How to include double quote on the alert message?
    function itry()
    {
        alert(+ "Greate" +);
    }
I want the word Greate has a double quote like this; "Greate"
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
you have to escape the double quotes like this:
 alert( "\"Greate\"");
http://www.w3schools.com/js/js_strings.asp
Maheshwar RSoftware Developer
Commented:
use the \" in your string

Author

Commented:
Hi! its working but what about if it is declared like this;
var ee = "Great";
Var ff = "Small";

alert()... Pls help its not working on me.
Maheshwar RSoftware Developer

Commented:
try the following
 function itry()
    {
        alert(+ \" ee  \"  +);
    }

Open in new window

Author

Commented:
Hi omaheshwar, Its not working. I've been tried many times...
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
var ee = "\"Great\"";
alert(ee);

or

var ee = "Great";
alert("\"" + ee + "\"");

Author

Commented:
Hi Guy, Its working Thanks both of you...