JSFiddle - React, Tailwind, and code Playground
HTML
<div id="views-field-field-section">
Lifestyle
</div>
<div id="views-field-field-section">
Politics
</div>
<div id="views-field-field-section">
Economy
</div>
<div id="views-field-field-section">
Local
</div>
<div id="views-field-field-section">
Sports
</div>
<div id="views-field-field-section">
News
</div>
CSS
#views-field-field-section{
background-color: red;
height: 100px;
width: 200px;
}
JavaScript
var colorInput = document.getElementById('views-field-field-section').textContent;
switch (colorInput) {
case 'Lifestyle':
document.getElementById('views-field-field-section').style.backgroundColor = '#9518b8';
break;
case 'Local':
document.getElementById('views-field-field-section').style.backgroundColor = '#009fe3';
break;
case 'Sports':
document.getElementById('views-field-field-section').style.backgroundColor = '#95c11f';
break;
case 'Economy':
document.getElementById('views-field-field-section').style.backgroundColor = '#d40d10';
break;
case: 'Politics':
document.getElementById('views-field-field-section').style.backgroundColor = '#ffcc00';
break;
default:
text ='Nix!';
break;
}