+ 2
Html font color
im aware of how to have a font color. But what is the best way to have a color pattern without having to place the font color code before and after each and every letter?
5 Réponses
+ 9
var textToChange = $("#txt").text();
for(var i = 0; i < textToChange.length; i++) {
var newSpan = $("<span />");
.text(textToChange[i]);
.css("color", i % 2 == 0 ? "green" : "red");
$("#txt").append(newSpan);
}
It's something like this.😉
+ 2
Using CSS you can assign colors to each type of element, class or ID. I strongly suggest you to make the sololearn's CSS course
+ 2
i will when i finish html, but will it show me how to insert a different color for each letter?
+ 2
now i understood what you want to do. To achieve this you should use a program language to manipulate the string and wrap each letter inside a HTML element. Then you could dynamically Collor each letter individually
+ 2
oh ok thats what i was avoiding but ok thanks Carlos