JSFiddle - React, Tailwind, and code Playground
HTML
<span id="result">0</span>
JavaScript
function getElementByIdCompatible (the_id) {
if (typeof the_id != 'string') {
return the_id;
}
if (typeof document.getElementById != 'undefined') {
return document.getElementById(the_id);
} else if (typeof document.all != 'undefined') {
return document.all[the_id];
} else if (typeof document.layers != 'undefined') {
return document.layers[the_id];
} else {
return null;
}
}
var sum1 = 220
var totalsum = sum1 * 4.6; // = 1012
var obj = getElementByIdCompatible('result');
obj.innerText = totalsum;