Say I want to set horizontal padding of a styled element to variable 'x' and set vertical to a variable 'y'. Of course, this is possible:
var docex = document.getElementById.style;
docex.paddingTop = y;
docex.paddingBottom = y;
docex.paddingLeft = x;
docex.paddingRight = x;
Is there a shorter way for me to do this, such as something akin to:
var docex = document.getElementById.style;
docex.paddingTop = docex.paddingBottom = y;
docex.paddingLeft = docex.paddingRight = x;
However, as I understand it, the above would not work and would declare a global variable, as I saw from another question on this site. So, what would be the most efficient minimal way for me to implement an idea similar to above, that is possible with vanilla javascript?
Thanks in advance!
document.getElementById('#id').style.cssText='padding: '+x+' '+y;