Access the -webkit- vendor prefix in JavaScript

倖福魔咒の 提交于 2019-11-29 06:46:38

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.

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");

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!