Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to make links in the tab contents force the tabs to switch, it helps to understand what is happening under the hood to make them switch by default.</p> <p>By default, mouseover events force the tabs to change; therefore, the solution is to override the default click event of the hyperlinks in question by binding an event to hyperlinks in the tab content:</p> <p><strong>Include this code after the JavaScript code you showed in your question, inside the $(document).ready</strong>:</p> <pre><code>$('.tabcontent').find('a').click(function() { event.preventDefault(); $('.tabs #' + $(this).attr("rel")).mouseover(); }); </code></pre> <p>The event.preventDefault() prevents the hyperlinks from attempting to redirect to the page entered in the href attribute, and the rel attribute is used as a way to bind the hyperlink to the specific tab being linked to.</p> <p>The rel attribute is used to get the value of the id of the tab so we can programmatically invoke its mouseover event, and switch tabs.</p> <pre><code>&lt;div class="tabscontainer"&gt; &lt;div class="tabs"&gt; &lt;div class="tab selected first" id="tab_menu_1"&gt; &lt;div class="link"&gt;JavaScript&lt;/div&gt; &lt;div class="arrow"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="tab" id="tab_menu_2"&gt; &lt;div class="link"&gt;CSS&lt;/div&gt; &lt;div class="arrow"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="tab last" id="tab_menu_3"&gt; &lt;div class="link"&gt;JQuery&lt;/div&gt; &lt;div class="arrow"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="curvedContainer"&gt; &lt;div class="tabcontent" id="tab_content_1" style="display:block"&gt;content for tab 1 &lt;a href="#" rel="tab_menu_2"&gt; tab2&lt;/a&gt;&lt;/div&gt; &lt;div class="tabcontent" id="tab_content_2"&gt;content for tab 2&lt;/div&gt; &lt;div class="tabcontent" id="tab_content_3"&gt;content for tab 3&lt;/div&gt; &lt;/div&gt; </code></pre> <p>In the HTML content for your tab, simply include the hyperlink as you normally would, using an href="#" and a rel attribute. The rel attribute must equal the id of the target tab, in this case, tab_menu_2.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload