简体   繁体   English

javascript webkitTransform样式属性未设置-范围?

[英]javascript webkitTransform style attributes not setting - scope?

I'm trying to set the webkitTransform style attribute, but it's not setting for some reason. 我正在尝试设置webkitTransform样式属性,但是由于某些原因未设置。 But there are other attributes that are successfully being set to the div. 但是还有其他成功设置为div的属性。

This doesn't work: 这不起作用:

var cell = document.createElement("div");
var canvas = document.createElement("img");

cell.className = "baz";
cell.appendChild(canvas);

cell.style.color = "bar";

cell.style.webkitTransform = "foo"; 

alert(cell.style.webkitTransform);  //doesn't work - returns empty  
alert(cell.style.color);            //doesn't work - returns empty
alert(cell.className);              //outputs "baz" -- works as expected

This is all nested inside a somewhat complex set of functions, where the consequences of scope aren't totally clear to me, but that doesn't seem to me to have anything to do with this... 这些全部嵌套在一组稍微复杂的函数中,其中作用域的后果对我来说并不十分清楚,但是在我看来,这与它没有任何关系...

thanks. 谢谢。

Try putting an actual transform on the div? 尝试在div上进行实际转换? Like cell.style.webkitTransform = "rotate(45deg)"; 像cell.style.webkitTransform =“ rotate(45deg)”;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM