1

I have a problem putting variable value in quotes in Jquery:

for example:

I have a Html color code in variable color, which has a value #FFFF00. I vant to display variable value like this: "#FFFF00".

I tried something like this but it didn't work:

context.strokeStyle = "\"color\"";
Erik
  • 335
  • 2
  • 9
  • 19

3 Answers3

5

If you want to display the string wrapped in quotes then simply use:

context.strokeStyle = '"' + color + '"';
David Thomas
  • 249,100
  • 51
  • 377
  • 410
4

Just use the variable directly.

context.strokeStyle = color;

and if you want to add quotes to it:

context.strokeStyle = """ + color + """;
Kevin B
  • 94,570
  • 16
  • 163
  • 180
0

You don't need the quotes.

context.strokeStyle = color;

Should do just fine.

Adrian
  • 42,911
  • 6
  • 107
  • 99