To a large extent, you can use the difficult task:
for (i=0;i<=lastSelector;i++) {
var e = mySelector[i];
e.style.WebkitTransition =
e.style.MozTransition =
e.style.OTransition =
e.style.MsTransition =
e.style.transition =
'opacity 1s';
e.style.opacity = 0;
}
Since there are several of these properties, where we have vendor-specific versions, you can consider a reuse function that does this, for example:
function setMultiVendorProp(style, propName, value) {
style[propName] = value;
propName = propName.substring(0, 1).toUpperCase() + propName.substring(1);
style["Webkit" + propName] = value;
style["Moz" + propName] = value;
style["O" + propName] = value;
style["Ms" + propName] = value;
return value;
}
Or use the dashed style instead, as we already use strings, not identifiers:
function setMultiVendorProp(style, propName, value) {
style[propName] = value;
style["-webkit-" + propName] = value;
style["-moz-" + propName] = value;
style["-o-" + propName] = value;
style["-ms-" + propName] = value;
return value;
}
Then:
for (i=0;i<=lastSelector;i++) {
var e = mySelector[i];
setMultiVendorProp(e.style, "transition", "opacity 1s");
e.style.opacity = 0;
}
Side notes:
- There is no
;after closing }in the operator for. var - , var () ; : , var