Great article, Samantha! The only question I had at the end was how to do the CSS ↔️ JS round trip for a global variable, as opposed to (as I understand it) your final example, which shows how to do it for a variable in local scope?
Great question @clozach
! You will have to go with the getComputedStyle route, but instead of passing the element, you just pass in document.documentElement. So something like this:
Great article, Samantha! The only question I had at the end was how to do the CSS ↔️ JS round trip for a global variable, as opposed to (as I understand it) your final example, which shows how to do it for a variable in local scope?
Great question @clozach ! You will have to go with the
getComputedStyle
route, but instead of passing the element, you just pass indocument.documentElement
. So something like this:(Let me update my official notes too 👏)