I want to make function that sets color of text based on first letter in that text.
I was looking for some solution for a while and couldnt find anything and dont know if it’s even possible.
Here’s what i want to achieve:
<h1> tag that is dynamically generated on multiple locations.
I wanto to achieve that for example if this text starts with A,B,C or D color is set to red
If it starts with E,F,G or H color is set to green etc for different letter and color combinations..
So for example
<h1 class="dynamic-color">Alphabet</h1> and
<h1 class="dynamic-color">Banana</h1> will be red
<h1 class="dynamic-color">Fireman</h1> and
<h1 class="dynamic-color">Grass</h1> will be green.
Is something like this even possible?