CSS:
.btn-category-list-col {
background:#f4f6f9;
border: 0 !important;
}
.btn-category-list-col:hover {
background: #E2EEFC;
}
.btn-category-list-col button:hover {
font-weight: bold;
}
.btn-category-list-col-click {
background: #E2EEFC;
}
.btn-category-list-col-click button {
font-weight: bold;
}
Looped button:
<td class="p-0 btn-category-list-col">
<button type="button" value="${cat.category_id}" class="category_sort btn float-left" data-toggle="modal" data-target="#createCategory">${cat.category_name}</button>
</td>
Script
$(document).on('click', '.category_sort', function (e) {
e.preventDefault();
$(".btn-category-list-col").toggleClass("btn-category-list-col-click");
});
https://i.sstatic.net/8yR2w.png
My question is about the onclick function in my script. When I click on a button, it changes the classes of all buttons instead of just the one clicked. How can I modify it to only affect the specific button that was clicked?