Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JavaScript将多个字符串设置为css属性?_Javascript_Jquery_Css - Fatal编程技术网

如何使用JavaScript将多个字符串设置为css属性?

如何使用JavaScript将多个字符串设置为css属性?,javascript,jquery,css,Javascript,Jquery,Css,请注意,我询问的是多个字符串,而不是多个属性 更具体地说,我正在寻找一种javascript/jquery方法来更改属性 此属性可以将多个字符串作为值。例如: grid-template-areas: "a b b" "a c d"; 要实现这一点,您需要在新的网格模板区域值中包含双引号。因此,您需要用单引号分隔新字符串。试试这个: $('#example-element').css('grid-template-areas', '"a b b" "a

请注意,我询问的是多个字符串,而不是多个属性

更具体地说,我正在寻找一种javascript/jquery方法来更改属性

此属性可以将多个字符串作为值。例如:

grid-template-areas: "a b b"
                     "a c d";

要实现这一点,您需要在新的
网格模板区域
值中包含双引号。因此,您需要用单引号分隔新字符串。试试这个:

$('#example-element').css('grid-template-areas', '"a b b" "a b b" "a c c"');

请注意,此CSS规则仅适用于现代浏览器(即,除ie和旧版本的Edge之外的所有浏览器,将值换行或屏蔽引号(或使用其他类型的引号作为分隔符):
el.style.gridTemplateAreas=`a c b”“a c d`;