Нужна функция, которая бы подсвечивала кнопку "удалить" при выборе хотя бы 1 чекбокса. Всё работает корректно, но после нажатия кнопки выбрать всё при нажатии на одиночный инпут состояние кнопки "удалить" не меняется. В чем может быть причина?
https://trytopersuademe.github.io/profileAB/index.html
const checkBoxAll = () => {
$(":checkbox").styler();
let checked = false;
$(".userProfile__select-All-Titles").click(function () {
if (checked) {
$(":checkbox").each(function () {
$(this).prop("checked", false).trigger("refresh");
});
countCheckedInputs();
checked = false;
} else {
$(":checkbox").each(function () {
$(this).prop("checked", true).trigger("refresh");
});
checked = true;
countCheckedInputs();
}
return false;
});
};
checkBoxAll();
const countCheckedInputs = () => {
let checkedInput = $(".checked").length;
console.log(checkedInput);
if (checkedInput > 0) {
$(".userProfile__delBTN").addClass("userProfile__delBTN_active");
} else {
$(".userProfile__delBTN").removeClass("userProfile__delBTN_active");
}
};
$(".jq-checkbox").on("click", function () {
countCheckedInputs();
});