Previously I was trying to create and alternate “add to cart” button on the single-product-page of a Woocommerce website. Now, I would like that button to link to a tab on the same page, have the page scroll down and switch to that tab when the button is clicked.
This is exactly what I need to happen but I do no know how to implement it in the wordpress setting.
So I settled for creating a js script by suggestion of this place
<script type="text/javascript">
if ( location.href.match(/#tab-reviews/g) !== null ) {
jQuery( '#tab-reviews' ).show();
jQuery( 'li.reviews_tab a' ).trigger('click');
}
</script>
Then I called it into word press through the funtion.php file with this, but its not working.
function tab_scroll() {
wp_enqueue_script('custom-script',
get_stylesheet_directory_uri() . '/tab_scroll.js',
array( 'jquery' ));
}
add_action( 'wp_enqueue_scripts', 'tab_scroll' );
I dont know if its the way i called the script or just that the script is not written to suit my needs or even written properly
What I would like is some help/suggestions on making the first script work for me. And help on bringing into wordpress.