Instead of using jQuery, you can achieve the same result with plain JavaScript and CSS variables. For example, you can set the scale property using
.css("scale", `${scale}`)
or
.css("scale", scale.toString())
as suggested by @Tom.
Here is an example using JavaScript and CSS Variable:
const a = 0.1;
const b = 0.1;
const scale = a + b;
document.querySelectorAll(".item").forEach((elItem) => {
elItem.style.setProperty("--scale", scale);
});
.item {
width: 100px;
height: 100px;
background: blue;
scale: var(--scale, 1); /* Use --scale CSSVar or default to 1 */
}
<div class="item"></div>
Check out MDN's guide on Using CSS custom properties
Learn more about CSS var() on MDN