views:

7428

answers:

3

Hi,

I want to change the -webkit-transform: rotate() property using Javascript dynamically. But the commonly used setAttribute is not working:

img.setAttribute('-webkit-transform', 'rotate(60deg)');

The .style is not working either..

How can I set this dynamically in Javascript? I know some of you have experience dealing with this before.

-

Thanks to all the guys that helped me out!

+3  A: 

Try using

img.style.webkitTransform = "rotate(60deg)"
Andrei Serdeliuc
+10  A: 

The JavaScript style names are WebkitTransformOrigin and WebkitTransform

element.style.webkitTransform = "rotate(-2deg)";

Check the dom extension reference for Webkit here.

Ólafur Waage
+1  A: 

You may try to switch between two pre-defined CSS classes using img.style.className.

Thevs