Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 5
How to change font size and color using JS only?
https://code.sololearn.com/W3ftikqMkuQc/?ref=app In this code I want to change the font-color and font-size of the characters being printed.
8 Respostas
+ 11
Since you can not directly change the style of a character the way you were told, this would be a solution:
function Hacker()
{
Ā Ā Ā Ā var nm = list.value;
Ā Ā Ā Ā var l = nm.length;
Ā Ā Ā Ā for(var a = 0; a <l; a ++)
Ā Ā Ā Ā {
Ā Ā Ā Ā Ā Ā Ā Ā var k = nm.charAt(a);
Ā Ā Ā Ā Ā Ā Ā Ā document.write('<span style = "color: red; font-size: 24px">' + k + '</ span> <br/>');
Ā Ā Ā Ā }
}
+ 7
let el = document.getElementsByTagName('p')[0];
el.style.color = '#fff';
el.style.fontSize = '16px';
That way you can do it. You can also obtain the element by its ID or its class, that depends on you.
+ 6
Hello, Aanisha Bhattacharyya !
Please try this example. In this code, javascript looks for an element by id, and replaces styles
var num = document.getElementById("id");
num.style.color = "red";
num.style.fontSize = "25px";
+ 5
Mickel ,you really helped.
This is my finished code and hope you like it.
https://code.sololearn.com/W3ftikqMkuQc/?ref=app
+ 5
Alexander Sokolov ,Peter Claver you all also helped.Please try my code ,my best till date.
https://code.sololearn.com/W3ftikqMkuQc/?ref=app
+ 3
document.getElementById('element id').style.color='blue';
+ 2
Peter Claver ,Mickel ,Alexander Sokolov
In this code I want to change the style and font-color of the characters being printed.
https://code.sololearn.com/W3ftikqMkuQc/?ref=app
+ 2
Mickel Thanks a lot.