Access the -webkit- vendor prefix in JavaScript

后端 未结 3 1374
独厮守ぢ
独厮守ぢ 2020-12-16 02:39

If I were writing a JavaScript line to set a style attribute of an element it could look like this (this example: \"width\"):

document.getElementById(\'myDiv         


        
3条回答
  •  难免孤独
    2020-12-16 03:00

    You have two options:

    • style["-webkit-transition"]
    • style.WebkitTransition

    The first directly works. The second notation is called camel case, and foo-bar-baz becomes fooBarBaz. As a result, when a non camel case string starts with -, the first letter is capitalized in camel case.

提交回复
热议问题