【发布时间】:2013-05-19 23:21:04
【问题描述】:
jQuery.camelCase 用于将虚线 CSS 属性转换为驼峰式 CSSOM(?或 DOM?)属性。
我想做相反的事情来动态创建 CSS 过渡值。
我不想为此使用 all 关键字。我想让不强制编码器只使用background-color 而不是backgroundColor 成为可能。
这可能吗(可能通过 jQuery)还是需要大量代码来支持跨浏览器?
编辑:
$("#example").css("transition-property", "backgroundColor") // Fail
我不想做与我的示例完全相同的操作,但这说明了问题。
我正在尝试遍历包含 css 属性和值的对象,以将对象键设置为转换属性。例如。 { backgroundColor: "red" } 应将 background-color 设置为 transition-property 而不是 backgroundColor。
【问题讨论】:
-
但是jQuery两者都接受,你为什么要这么做?
-
是的,但我不需要这个属性名称本身。我需要它来设置
transition值,例如transition: backgroundColor 1s将失败。还是不行?
标签: javascript jquery css css-transitions camelcasing