You only pass the value of this attribute to the function, so you don't change the style element, you only change the value, can do it in this way:
function doubleup(attr){
return attr*=2;
}
myDIV.style.opacity = doubleup(myDIV.style.opacity);
myDIV.style.zIndex = doubleup(myDIV.style.zIndex);
By the way, you have to use zIndex
instead of z-index
to manipulate this value.
Another possible solution is:
function doubleup(el){
el.style.opacity*=2;
}
function doubleupZIndex(el){
el.style.zIndex*=2;
}
doubleupOpacity(myDIV);
doubleupZIndex(myDIV);