I am populating my h1 id-categoryOutput with a word from a JS database, Taffy DB. (The word is the name of the selected category.) That h1 is wrapped in a div id=banner to provide a gray banner background. I want to style that div a different color based on the category word in h1. See the HTML here:
I’m sure that would work, but it won’t show because of the above error. Not sure what other order to put the lines in. If I put the lines in near the bottom of the code, it replaces the category name in h1. I think the problem is in the syntax of
db({category:show}).each(function (name){
var category = name.category;
var sendOutput = document.getElementById('categoryOutput');
sendOutput.innerHTML = "" + category;
// Set div color
if (category="General") {
document.getElementById('banner')
.classList.replace('grayed', 'bg-general')}
else if (category="Electrical") {
document.getElementById('banner')
.classList.replace('grayed', 'bg-electrical')}
Unfortunately, the color goes white no matter which category I choose.