Access the -webkit- vendor prefix in JavaScript

后端 未结 3 1349
独厮守ぢ
独厮守ぢ 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 02:51

    If you don't want to keep digging up those pesky style properties and their naming conventions you can always use jQuery to keep it simple.

    $('#myDiv').css("-webkit-transition", "value");
    
    0 讨论(0)
  • 2020-12-16 02:52

    One possibility would to use for example jquery, to make it easy. If you want a pure javascript solution, then read this: http://www.javascriptkit.com/javatutors/setcss3properties.shtml

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题