+ 3

Use CSS on text created by JavaScript

Can you style text created by JavaScript with CSS?

20th Feb 2017, 4:59 PM
Bart
Bart - avatar
2 Answers
+ 3
like this. elem = document.getElementById(elemId); elem.style.background = 'white';
20th Feb 2017, 5:22 PM
Roger C
Roger C - avatar
+ 3
Text created by JS as text node elements, are necessarly put in another existing element on the page, so they inherit from styles of their parents, and you can dynamically change attributes and/or css properties as you want ^^
21st Feb 2017, 5:03 AM
visph
visph - avatar