我收到一条错误消息(语法错误:赋值中的左侧无效(,其中包含以下代码行:
document.getElementById("wrapper").style.grid-template-rows = "1fr 300px repeat(2, 1fr)";
您不能键入网格模板行作为要更改的内容吗?有没有其他方法可以使用JavaScript更改网格模板行?
更改属性名称。
JS中CSS属性的名称略有不同。使用驼峰大小写而不是连字符:
document.getElementById("wrapper").style.gridTemplateRows = "50px";