如何定义常量以用于webkitTransition?

时间:2012-09-06 19:46:41

标签: javascript

如何重写以下内容以使用变量:

element.style.webkitTransition = "opacity 1.0s ease";

我尝试了这些,但没有一个有效:

var kDuration = 1.0;
element.style.webkitTransition = "opacity kDurations ease";

var kDuration = 1.0;
element.style.webkitTransition = "opacity kDuration ease";

var kDuration = 1.0;
element.style.webkitTransition = "opacity kDuration s ease";

var kDuration = 1.0;
element.style.webkitTransition = "opacity kDuration + s ease";

var kDuration = 1.0s;
element.style.webkitTransition = "opacity kDuration ease";

1 个答案:

答案 0 :(得分:0)

var kDurationfirst = "1.0s"; var kDuration= "opacity "+kDurationfirst +" ease";
element.style.webkitTransition = kDuration ;