I have a button that I want to change its color when the user clicks on it, but it doesn't work and I can't figure out why.
This is what I've tried until now.
$(document).ready(function() {
});
$('#canvasButtons button').click(function () {
$('#canvasButtons').children().removeClass('selected-button');
$(this).addClass('selected-button');
});
.video-buttons button {
width: 200px !important;
height: 66px !important;
background-color: #484848 !important;
cursor: pointer !important;
margin-right: 50px;
}
.selected-button {
background-color: red !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div style="display: flex; align-items: center; flex-direction: column;" class="video-buttons" id="canvasButtons">
<button id="modifyButton">
<div class="vertical-line"></div>
<span>Modify B Box</span>
</button>
</div>
I've added the code snippet here. Can you please let me know why it doesn't work?