[Edit] Unlike some other questions on Stackoverflow, I am not looking just to scroll to an anchor. I need the page to scroll to the tabs, open and make the tab active, and then scroll the rest of the way to the anchor.
I am looking for some help with some code, but it is a bit hard to explain. I am rather new to Javascript and will provide as much detail as I can.
I have some regular tabs, each with some content within them. One of the tabs is a table of product comparisons. Above the tabs on the same page, I have an a href linked to an anchor. What I am trying to achieve is, through Javascript, if a user clicks the external link, it will:
- Scroll to the tabs section of the website
- Click the "Compare Configurations"tab that has the table (this will have the anchor on it.)
- Scroll to the anchor within that tab.
An example of what I am trying to achieve is similar to the GoPro website: EXAMPLE
When you click on the "Compare Editions" (below the PayPal part), it scrolls the page to the correct tab, opens it, and displays the table. That is what I am trying to achieve.
So far, I have the following code for my tabs:
<ul id="tabs">
<li class="active">FEATURES</li>
<li>SPECIFICATIONS</li>
<li>COMPARE CONFIGURATIONS</li>
</ul>
<ul id="tab">
<li class="active">
This is the first tab.
</li>
<li>
<br>
This is the second tab.
</li>
<li>
<br>
This is the third tab.
</li>
</ul>
Is there any way to get what I am trying to achieve with Javascript or the like? I am open to any and all suggestions and appreciate any help with this. If you would like to see my page and see how the page is laid out with the tabs, feel free to visit my site.