开发者

How to make this script works

开发者 https://www.devze.com 2023-01-17 00:38 出处:网络
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 p
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

0

精彩评论

暂无评论...
验证码 换一张
取 消