Changing the color of a parent div to the color of active child element on click

Pretty much what’s written above, I want to change the color of the container div so that it reflects the color of specific selected active elements.

So for example, the container’s background is a shade of grey – when I click on the element, the element contains a blue background. I want that blue background to then fill the grey element. And so on and so forth with different selected elements and colors. I only included one element, but at least 4 more elements will need this coding.

I imagine this needs to be done with Javascript? I have seen solutions for on hover and they required JS.


<div id="tabTopBar">
        <div class="tabTop">
            <a id="armory" href="armory.html" class="active">Armory</a>
            <a id="peerless" href="peerless.html">Peerless</a>
        </div>
    </div>

Respective css


#tabTopBar {
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: #dddddd;
}

.tabTop {
    overflow: hidden;
    border: 1px solid black;
    background-color: gray;
}

#armory.active {
    background-color: #0e343d;
    color: white;
    pointer-events: none;
}

#armory:hover {
    background-color: #879a9e;
    color: black;
}

#peerless.active {
      background-color: #bab757;
      color: white;
      pointer-events: none;
}

#peerless:hover {
      background-color: #dcdbab;
      color: black;
}

#tabTopBar {
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: #dddddd;
}

.tabTop {
    overflow: hidden;
    border: 1px solid black;
    background-color: gray;
}

.tabTop a {
    float: left;
    color: #f2f2f2;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
    font-size: 17px;
}

#armory.active {
    background-color: #0e343d;
    color: white;
    pointer-events: none;
}

#armory:hover {
    background-color: #879a9e;
    color: black;
}

#peerless.active {
    background-color: #bab757;
    color: white;
    pointer-events: none;
}

#peerless:hover {
    background-color: #dcdbab;
    color: black;
}
   <div id="tabTopBar">
        <div class="tabTop">
            <a id="armory" href="#armory" class="active">Armory</a>
            <a id="peerless" href="#peerless">Peerless</a>
        </div>
    </div>