1

I have a series of custom tabs on a Magento 2 product details page that were setup via the catalog_product_view.xml file.

I am trying to setup a button that will allow me to link from the short description area to additional tab.

If I do a brand new request to <a href="https://domain.com/product.html#additional">Additional</a> - it works fine, but reloads the entire page.

If I do an internal link to <a href="#additional">Additional</a> it does not work.

Any help is greatly appreciated.

1 Answer 1

4

I think you should do just trigger a click event for the tab on your button click if you just want to display on click like

add below script in your details.phtml file

<script type="text/javascript">
        require([
        'jquery'
    ], function ($) {
        'use strict';
            $("#your-button-id").on("click" ,function() {
//                console.log('48');
                //your a tag id like below
                $("#tab-label-reviews-title").trigger( "click" );
            });
});
</script>

run this commans

php bin/magento cache:clean && php bin/magento cache:flush

1
  • 1
    This worked. One thing I had to contend with was that my custom tab had a period in the id, so I had to rename it so that jquery wouldn't flake out.
    – Adam R.
    Oct 22, 2018 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.