简体   繁体   中英

javascript webkitTransform style attributes not setting - scope?

I'm trying to set the webkitTransform style attribute, but it's not setting for some reason. But there are other attributes that are successfully being set to the 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? Like cell.style.webkitTransform = "rotate(45deg)";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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