How to set browser specific css in JavaScript?

前端 未结 5 1220
再見小時候
再見小時候 2021-01-13 17:48

How to set style -webkit-box-shadow: 0px 0px 11px #000 to an element via JavaScript?

5条回答
  •  失恋的感觉
    2021-01-13 18:19

    Since I haven't yet seen a code example that works without jQuery, here's one:

    document.getElementById("test").style.webkitBoxShadow = "0px 0px 11px #000";
    

    Note that the javascript property is not the same as the CSS property. The javascript properties do not use a dash and use camelCase instead.

    And, a working demo here: http://jsfiddle.net/jfriend00/4LT7u/

提交回复
热议问题