I am modifying CSS attributes of a div in vanilla JS. When I grab the value, it's a string with px on the end, like '340px' so I can't just add a number directly. I end up doing this:
element.style.top = element.style.top.split("px")[0]+pixelsToAdd;
It works fine, but it feels hacky. Is there a more direct way to grab and set the value, or is this it?