Skip to content

Snippet: Enable Tabindex for the WPBakery FAQ Toggle Element

IMPORTANT: This function is already built-into Total 4.5+

// Open toggle on focus
function myprefix_vc_toggle_tabindex() { ?>

	
		( function( $ ) {
			'use strict';
			$( document ).on( 'ready', function() {
				var $toggles = $( '.vc_toggle' )
				$toggles.each( function() {
					var $this = $( this );
					$this.attr( 'tabindex', 0 );
					$this.focus( function() {
						$( '.vc_toggle_active' ).each( function() {
							var $el = $( this );
							$el.find( '.vc_toggle_content' ).slideUp( {
								duration: 300,
								complete: function () {
									$el.removeClass( 'vc_toggle_active' );
								}
							} );
						} );
						$( this ).find( '.vc_toggle_title' ).trigger( 'click' );
					} );
				} );
			} );
		} ( jQuery ) );
	

<?php }
add_action( 'wp_footer', 'myprefix_vc_toggle_tabindex' );
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)
Back To Top