Created
January 19, 2018 10:04
-
-
Save rvdsteege/e49f1893e9da74d99eb69844d29cc492 to your computer and use it in GitHub Desktop.
jQuery script to be able to link to WooCommerce tabs from anywhere on the page. Use link href "#wc-tab-XXX" (XXX corresponds to name of the tab as used by WooCommerce; use browser developer tools to determine).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Link to WooCommerce tabs from anywhere on the page. | |
* | |
* Example usage: | |
* <a href="#wc-tab-description">Description</a> | |
* <a href="#wc-tab-reviews">Reviews</a> | |
*/ | |
$( document ).on( 'click', 'a[href^="#wc-tab"]', function( e ) { | |
if ( e.preventDefault ) { | |
e.preventDefault(); | |
} | |
var tab = $( this ).attr( 'href' ).replace( 'wc-tab-', 'tab-' ); | |
$( '.wc-tabs-wrapper .wc-tabs a[href="' + tab + '"]' ).click(); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment