(function ($) {
    $.fn.customCheckbox = function (data) {
        this.each((index, value) => {
            generateCustomCheckbox($(value));
        });
    };

    function generateCustomCheckbox($element) {
        if ($element.parent("label.custom-checkbox-container").length > 0) return;

        if ($element.parent("label").length > 0) {
            let container = $element.parent("label");
            container.addClass("custom-checkbox-container");
        }
        else {
            let container = $("<label class='custom-checkbox-container'></label>");
            $element.wrap(container);
        }

        $element.after("<span class='custom-checkbox-checkmark'></span>");
    }
}(jQuery));

$(document).ready(function () {
    $(".custom-checkbox").customCheckbox();
});