What you need to do is get both the CSS files computed style and the inline style and add them both together
I used the following function to get the CSS files style:
https://stackoverflow.com/a/27527462/5814976
(Thanks Dude! https://stackoverflow.com/users/3894981/dude)
var cssElm = getStyle('.element'),
cssVal = cssElm.split('margin:')[1].split(';')[0],
then used the vanilla blah.style
to retrieve the inline style (this only fetched the highest ranking style so if you had an !important
tag in your CSS file it would just get that again and the end result would be 40px).
inlineVal = elm[0].style.margin,
Then we clean up both of the strings we retrieved (to remove any units that have applied (em, px etc) and then add them together:
totalVal = parseInt(cssVal.replace(/[^0-9.]/g, "")) + parseInt(inlineVal.replace(/[^0-9.]/g, ""));
and lastly reapplied the style to the original element.
elm[0].style.margin = totalVal + 'px';
you can see a working example here:
https://jsfiddle.net/mdhkxhhd/