About 430,000 results
Open links in new tab
  1. Access CSS variable from javascript - Stack Overflow

    Is there a way to access a css variable from javascript? Here my css variable declaration. :root { --color-font-general: #336699; }

  2. How to Get and Set CSS Variable Values with JavaScript - David …

    Oct 8, 2018 · To set the value of a CSS variable using JavaScript, you use setProperty on documentElement 's style property: .setProperty('--my-variable-name', 'pink'); You'll …

  3. CSS Change Variables With JavaScript - W3Schools

    CSS variables have access to the DOM, which means that you can change them with JavaScript. Here is an example of how you can create a script to display and change the --blue variable …

  4. How to get and set CSS variables with JavaScript - byby.dev

    Jul 20, 2023 · To get the value of a CSS variable with JavaScript, you can use the getComputedStyle () function. This function returns an object that contains the computed …

  5. The easiest way to get and set CSS Variables in JavaScript

    Dec 5, 2023 · Getting CSS Variables with JavaScript. You can use getComputedStyle and getPropertyValue to get the CSS Variable in JavaScript. Here’s the syntax: getComputedStyle …

  6. How to Get Current Value of a CSS Property in JavaScript

    Jan 9, 2024 · In this article, we will see how to get the current value of a CSS property using JavaScript. Below are the approaches used to Get Current Value of a CSS Property in …

  7. How to Get the Value of a CSS Variable Using JavaScript?

    Nov 1, 2020 · You can get the value of a CSS variable (aka CSS custom properties) via JavaScript in the following way: Get the computed styles with the getComputedStyle() method, …

  8. Get and Set CSS Variables with JavaScript - Online Tutorials …

    To get and set CSS variables with JavaScript, we can use various methods. The getComputedStyle () method gives an object which includes all the styles applied to the target …

  9. Get a CSS value with JavaScript - Stack Overflow

    Jun 14, 2011 · I know I can set a CSS value through JavaScript such as: document.getElementById('image_1').style.top = '100px'; But, can I get a current specific style …

  10. Sharing a Variable Across HTML, CSS, and JavaScript

    Jan 13, 2025 · In JavaScript, you can interact with CSS variables using the getComputedStyle and setProperty methods: To read the current value of a CSS variable: To update the value …

  11. Some results have been removed
Refresh