引号中的JQuery变量值

Eri*_*rik 0 javascript jquery

我在Jquery中将变量值放在引号中时遇到问题:

例如:

我有一个可变颜色的Html颜色代码,其值为#FFFF00.我想显示这样的变量值:"#FFFF00".

我试过这样的东西,但它不起作用:

context.strokeStyle = "\"color\"";
Run Code Online (Sandbox Code Playgroud)

Dav*_*mas 5

如果要显示包含在引号中的字符串,则只需使用:

context.strokeStyle = '"' + color + '"';
Run Code Online (Sandbox Code Playgroud)