How to make this script works
dom.style.-webkit-t开发者_开发技巧ransform ='rotate(-90deg)';
In Chrome it tell: "Uncaught SyntaxError: Unexpected token -"
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';
document.getElementsByClassName('rotate-button')[0].style.WebkitTransform = 'rotate(-90deg)';
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
精彩评论