How to add a link on the page that opens a specific tab

Created on 9 August 2012, over 12 years ago
Updated 5 October 2023, over 1 year ago

I have been trying to figure this out for a few hours, and it isn't working. Basically, on the frontend of a node with horizontal tabs, I need to have additional links that can switch the display of the tabs to the specific tab. My guess was to use the fragment url (#some_fieldset_id), but that does not work. It only switches to that tab if the page is loaded with that fragment, not when the link href is the fragment.

The other solution I have tried has been to trigger a click on the tab element, but no luck there either. The short code I tried unsuccessfully was this:

$('.horizontal-tab-button-1').trigger('click');

Does anybody have a quick and easy solution?

Much appreciated!

💬 Support request
Status

Fixed

Version

1.0

Component

User interface

Created by

🇨🇦Canada pmusaraj

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada dadderley Vancouver

    The code in #4 works really well in Horizontal Tabs.

    One thing though, if you use
    <a href="#" class="open-tab-1">open</a>
    it will open the tab but go to the top of the page.

    This works much nicer
    <a href="javascript:void(0);" class="open-tab-1">open</a>

Production build 0.71.5 2024