JSFiddle - React, Tailwind, and code Playground
HTML
<div class="lol">
<span class ="loool">input</span></div>
<span class="percent-holder">100%</span>
<span>output</span>
<span >1070%</span>
CSS
.blue {
background-color: #00f;
color: #fff;
}
.red {
background-color: #f00;
color: #000;
}
JavaScript
$( 'span' ).each( function()
{
var $this = $( this ),
classToAdd = null;
switch( $this.text() )
{
case 'input':
classToAdd = 'blue';
break;
case 'output':
classToAdd = 'red';
break;
}
if( classToAdd !== null )
{
$this.addClass( classToAdd );
}
} );