jQuery(document).ready(function($) {
        // Tabs
        $('.occasion-accessoires-tabs .tabs a').on('click', function(e) {
            e.preventDefault();
            let target = $(this).attr('href');
            $('.tab-content').hide();
            $(target).show();
            $('.occasion-accessoires-tabs .tabs a').removeClass('active');
            $(this).addClass('active');
        });
        $('.occasion-accessoires-tabs .tabs a').first().click();

        // Add row
        $('.add-row').on('click', function() {
            let group = $(this).data('group');
            let $table = $('#occasion-'+group+'-table tbody');
            let index = $table.find('tr').length;
            let row = `
                <tr>
                    <td><input type="number" name="`+group+`[`+index+`][prioriteit]" value=""></td>
                    <td><input type="text" name="`+group+`[`+index+`][omschrijving]" value="" style="width:100%;"></td>
                    <td><button type="button" class="button remove-row">X</button></td>
                </tr>
            `;
            $table.append(row);
        });

        // Remove row
        $(document).on('click', '.remove-row', function() {
            $(this).closest('tr').remove();
        });
    });