There are three buttons, each button has its own color.
But the problem is that I click on 1 - the color is active, I press on 2 - the color is also active.
And it is necessary to click on 2 and 1 color is gone.
Here is my code:
$('.first').click(function(){ $('#active1').css('background-color', '#339999'); }) $('.firsts').click(function(){ $('#active2').css('background-color', '#339933'); }) $('.firstss').click(function(){ $('#active3').css('background-color', '#993399'); }) *{ box-sizing: border-box; padding: 0; margin: 0; } body { font-size: 16px; font-family: "Poppins", Arial; /* background-color: #a7a6a6; */ } .menu { width: 50%; margin: 0 auto; padding-top: 50px; display: flex; } .menu button { padding: 10px; border-radius: 5px; } .firsts { color: red; } <div class="menu"> <div class="first"><button id="active1">6</button></div> <div class="firsts"><button id="active2">12</button></div> <div class="firstss"><button id="active3">24</button></div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="script.js"></script>