-1

I noticed how CSS has Cross-Browser arguments such as -webkit-, and -moz- as well as Media Queries. Does JavaScript Have an equivalent using element.style.["Cross-Browser]; or any other method? I usually use JavaScript to define all of my elements and I am considering switching to HTML and CSS. Here is an example for this problem is:

CSS

#div{
    -webkit-padding:4px;
    -moz-padding:4px;
}

JavaScript

window.addEventListener("load", Start);
function Start(){
    var Div = getElementById("div");
    Div.style.padding = "4px"; //Universal [Works!]
    Div.style.moz.padding = "4px"; //Firefox [Doesn't Work! Why?]
    Div.style.mozPadding = "4px"; //Firefox [Doesn't Work! Why?]
    Div.style.webkit.padding = "4px"; //Chrome or Opera [Doesn't Work! Why?]
    Div.style.webkitPadding = "4px"; //Chrome or Opera [Doesn't Work! Why?]
    document.body.appendChild(Div);
}

1 Answers1

0

I think you would use the same string as with css, but with the following syntax because of the dashes.

Div.style["-webkit-padding"] = "4px";
user3432422
  • 1,359
  • 1
  • 11
  • 13