+ 1
Color text
Hello, I'm new at learning Web (Js) and I would need to know how can I change the text's colour? Like from black to orange.
2 Réponses
+ 1
Before to learn change color, you should learn how to set HTML tad and id.
Once you have your text with HTML tag and id, you can use document.getElementById to access that DOM element.
From the return of the DOM variable, you can access the color selector using style method.
For example:
to set a text with class name of txt in HTML
<p class="txt">Text</p>
to access that DOM element, in JavaScript:
var txt = document.getElementById('txt');
finally use style method to change the css color:
txt.style.color = 'orange';
+ 1
Thank you Calvin.