JSFiddle - React, Tailwind, and code Playground
by Ian Roberts
HTML
<li id="categoryname">Softball Goods</li>
CSS
/*element content as class*/
.softballgoods {
color:#187089;
}
/*page title as class*/
.jsfiddle { /*only need a part fo the class*/
color:#fad400;
}
JavaScript
//add class to body based on title tag
//add class based on page title
//add class to body based on title with jquery or javascript
//below works - via - http://stackoverflow.com/questions/3862820/jquery-how-to-addclass-based-on-the-content-of-an-element
//$('#categoryname').each(function() {
// var className = $(this).html().replace(' ', '').toLowerCase();
// $(this).addClass(className);
//});
//mod a bit & it works for page title added as class for body
$('title').each(function() {
var className = $(this).html().replace(' ', '').toLowerCase();
$('body').addClass(className);
});