+ 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
4 odpowiedzi
+ 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";
+ 2
It worked , thanks
0
How about the font-size and others ?
- 1
document.getElementById("you").setAttribute("style", "color: green;");
// or:
document.getElementById("you").style = "color: green;";
// or:
document.getElementById("you").style.color = "green";