Snippet: Close VC Tabs First Active Tab on Mobile Devices
add_action( 'wp_footer', function() { ?>
( 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 );
<?php } );
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
We recommend Code Snippets (100% Free) or WPCode (sponsored)