how to change a css variable with javascript
document.documentElement.setAttribute("style", "--main-background-color: green");let root = document.documentElement;
root.addEventListener("mousemove", e => {
root.style.setProperty('--mouse-x', e.clientX + "px");
root.style.setProperty('--mouse-y', e.clientY + "px");
});document.documentElement.style.setProperty("--main-background-color", "green");
var root = document.querySelector(':root');
root.style.setProperty('--variable', 'lightblue');
/or/
root.style.setProperty('--variable', myColor);
Also in JavaScript:
- Property 'find' does not exist on type NodeListOf
- import a script to my react componetn
- jquery replace text in div
- rounding off numbers javascript
- add option to select jquery
- watch file in changes in webpack
- how to save image in fabruc js json
- angular flex layout
- react fragment
- how to use the onload event n vue js
- use theme in component mui
- moment js date diff
- pdf.js change background color
- dynamodb get all items nodejs
- jquery run after page load
- convert json to object
- ajax file upload from modal
- javascript format date
- get selected option value
- javascript range slider
- js check if undefined
- slick js's alternatives
- get contents between tags javascript
- jquery if attribute