Answers for "get css custom property javascript"

1

get css custom property javascript

/* This will return the value of the --color custom property
   from the root element */
getComputedStyle(document.documentElement).getPropertyValue('--color')

const customButton = document.querySelector('.custom-btn')
/* This will return the value of the --color custom property
   from the root element since it is inherited down to the
   customButton element. */
getComputedStyle(customButton).getPropertyValue('--color')

/* This will return the value of the --background-color
   custom property from this customButton element */
getComputedStyle(customButton).getPropertyValue('--background-color')
Posted by: Guest on April-16-2022

Code answers related to "get css custom property javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language