+ 1

How do I change the color of my font , font-family , font-size and font align to left

<button onclick="f()"> click me </button> <p id="you"> you good </p> function f() { document.getElementById("you").innerHTML = "lol"; document.getElementById("you").element.setAttribute("style", "color: green;"); } This code only changes to lol

31st Mar 2018, 6:06 PM
klisco1
4 Réponses
+ 3
document.getElementById("you").style = "color: green; font-size:20px; text-align:left;"; // or: document.getElementById("you").style.color = "green"; document.getElementById("you").style.fontSize = "20px"; document.getElementById("you").style.textAlign = "left";
31st Mar 2018, 6:27 PM
visph
visph - avatar
+ 2
It worked , thanks
31st Mar 2018, 6:33 PM
klisco1
0
How about the font-size and others ?
31st Mar 2018, 6:25 PM
klisco1
- 1
document.getElementById("you").setAttribute("style", "color: green;"); // or: document.getElementById("you").style = "color: green;"; // or: document.getElementById("you").style.color = "green";
31st Mar 2018, 6:23 PM
visph
visph - avatar