lundi 23 août 2021

Styling a checkbox on webflow and jQuery

I am building a site on webflow and am trying to have a form that has some checkboxes to select several services. I'm trying to add style the checkboxes when they are checked (add a background color and change the color of the label and icon from black to white, but the code jQuery code that I implemented isn't cutting it. I have multiple boxes, so adding unique IDs would make things overly complicated. This is what I have so far:

<script>
$('.checkbox-wrapper').on('click', function() {
    if (!$(this).find('.checkbox-button').is(':checked') {
        $(this).removeClass('active');
        $(this).find('.checkbox-label').removeClass('active');
        $(this).find('.checkbox-icon').removeClass('active');
    } 
    else {
        $(this).addClass('active');
        $(this).find('.checkbox-label').addClass('active');
        $(this).find('.checkbox-icon').addClass('active');
    }
});
</script>



Aucun commentaire:

Enregistrer un commentaire