tags:

views:

43

answers:

3
dom.style.-webkit-transform ='rotate(-90deg)';  

In Chrome it tell: "Uncaught SyntaxError: Unexpected token -"

+4  A: 

a) The - char is the subtraction operator and is not valid for use as part of an identifier in JavaScript.

b) I would define a pre-existing CSS class that has the behavior that you want, then just append the class to the class attribute:

CSS:

.transform {
   -webkit-transform: rotate(-90deg);
}

JavaScript:

document.getElementsByClassName('rotate-button')[0].className += ' transform';
Jacob Relkin
B=> Ok, this is just a example, can you make this script works. But the value of transform is a variable, so i want to change it in js, not css
Snoob
Also be aware that `document.getElementsByClassName` is not completely cross-compatible.
Kevin
I want the class transform in js, not css
Snoob
The property is `.className` by the way. And you might want to add a space to each end of `transform` to ensure two class names don't run together.
Kevin
+2  A: 

document.getElementsByClassName('rotate-button')[0].style['-webkit-transform'] ='rotate(-90deg)';

- is the minus operator in javascript and you can't use it in a property directly

Knio
Thanks .........
Snoob
+2  A: 
document.getElementsByClassName('rotate-button')[0].style.WebkitTransform = 'rotate(-90deg)';
jerone