<分区>
<分区>
我想在样式对象中提交我自己的变量。我会告诉你我的意思:
var example = background
element.style.example // example is equal to the variable up top
这样做有什么用吗?
最佳答案
假设您想定义要动态设置的属性,您可以使用以下方法:
var example = 'background';
element.style[example] = 'black';
关于javascript - 在js样式对象中设置自己的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40896758/