How to change css of ternary operator based on the word? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to change css of ternary operator based on the word?

I have the following : <td>${person.gender ? 'Male' : 'Female'}</td> I want to add some css that will make the text Blue when the work is "Male" and Pink when the word is "Female". Any idea how this may be achieved?

2nd Oct 2020, 5:19 PM
MBanski
MBanski - avatar
1 Answer
0
Create a CSS class .male {color: blue;} and .female {color: pink;} and wrap the text 'Male' or 'Female' inside a <span> which applies either .male or .female as value for "class" attribute.
2nd Oct 2020, 5:25 PM
Ipang