Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

typescript css variables html

const styling: { name: string, value: string }[] = [
	{ name: "--primary", value: "#123456" }
];

let styleElement: HTMLElement = document.createElement( 'style' );
let cssVariable: string = '';

for ( let i = 0; i < styling.length; i++ ) {
  cssVariable += styling[i].name + ':' + styling[i].value + ';';
}

styleElement.innerText = ':root { ' + cssVariable + ' }';
document.getElementsByTagName( 'head' )[0].appendChild( styleElement );
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to save cookie in JavaScript 
Javascript :: click outside element jquery 
Javascript :: react native check os 
Javascript :: javascript generate 3 numbers 1 - 49 
Javascript :: package.json tilde vs caret 
Javascript :: electronjs npm start in full screen 
Javascript :: loadash sort by order of another array 
Javascript :: how to test usestate in jest 
Javascript :: GET req with js 
Javascript :: setinterval vs settimeout js 
Javascript :: sequelize.org findById 
Javascript :: html javascript find data attribute 
Javascript :: jquery trigger event when scroll to div 
Javascript :: redux logger 
Javascript :: How do I push an element into the array within an object in AngularJS 
Javascript :: how to run different node app on server different domains 
Javascript :: javascript get distinct values from array 
Javascript :: mongoose find and update prop 
Javascript :: xhr post send 
Javascript :: how to check if array is empty or not in javascript 
Javascript :: window.onload in javascript 
Javascript :: react cdn 
Javascript :: javascript remove empty object items 
Javascript :: how to comment in the react javascript 
Javascript :: jquery check if type is checkbox 
Javascript :: use import in node 
Javascript :: how to fetch api in reactjs using axios 
Javascript :: how to check which key is pressed in jquery 
Javascript :: regex contains string in end 
Javascript :: javascript check if object property exists 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =