I'm currently utilizing the Bootstrap Tree to generate a nested checkbox list (). However, I am looking to enhance the user experience by highlighting the checked items, and ensuring that when a parent is selected, its children are also highlighted. While I've made some progress with this functionality, I've encountered an issue where the background-color of individual child items won't toggle correctly when unchecked. It seems to only work when the parent item is not selected.
$(function checkbox() {
$("input[type='checkbox']").change(function () {
$(this).siblings('ul')
.find("input[type='checkbox']")
.prop('checked', this.checked);
$(this).parent('li').toggleClass("highlight");
});
});