Snippets: Close VC Tabs First Active Tab on Mobile Devices

add_action( 'wp_footer', function() { ?>
    
    <script>

        ( function( $ ) {
            'use strict';

                // Get viewport width
                var e = window, a = 'inner';
                if ( ! ( 'innerWidth' in window ) ) {
                    a = 'client';
                    e = document.documentElement || document.body;
                }
                var viewportWidth = e[ a+'Width' ];

                // Remove active class for tabs on windows smaller then 768 on load
                if ( viewportWidth < 768 ) {

                    $( '.vc_tta-tabs .vc_tta-panel' ).removeClass( 'vc_active' ).addClass( 'vc_was_active' );

                }


        } ) ( jQuery );

    </script>

<?php } );
All PHP snippets should be added via a child theme's functions.php file.