Note that there are some explanatory texts on larger screens.

plurals
  1. POControlling visibility of 2 divs simultaneously
    primarykey
    data
    text
    <p>I'm trying to use a tabbed interface to display content on a website. The first set of divs is the content (text) and the second is an associated image in a div outside the div containing the text as follows:</p> <pre><code>&lt;div id="side-img-container"&gt; &lt;div class="side-img" id="image_1"&gt;&lt;img src="image1.jpg" /&gt;&lt;/div&gt; &lt;div class="side-img" id="image_2"&gt;&lt;img src="image2.jpg" /&gt;&lt;/div&gt; &lt;div class="side-img" id="image_3"&gt;&lt;img src="image3.jpg" /&gt;&lt;/div&gt; &lt;div class="side-img" id="image_4"&gt;&lt;img src="image4.jpg" /&gt;&lt;/div&gt; &lt;div class="side-img" id="image_5"&gt;&lt;img src="image5.jpg" /&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="content&gt; &lt;ul class="tabs"&gt; &lt;li&gt;&lt;a href="#tab_1"&gt;Tab 1&lt;/a&gt;&lt;/div&gt; &lt;li&gt;&lt;a href="#tab_2"&gt;Tab 2&lt;/a&gt;&lt;/div&gt; &lt;li&gt;&lt;a href="#tab_3"&gt;Tab 3&lt;/a&gt;&lt;/div&gt; &lt;li&gt;&lt;a href="#tab_4"&gt;Tab 4&lt;/a&gt;&lt;/div&gt; &lt;li&gt;&lt;a href="#tab_5"&gt;Tab 5&lt;/a&gt;&lt;/div&gt; &lt;/ul&gt; &lt;div class="tab_container"&gt; &lt;div class="tab_content" id="tab_1"&gt;Content 1&lt;/div&gt; &lt;div class="tab_content" id="tab_2"&gt;Content 2&lt;/div&gt; &lt;div class="tab_content" id="tab_3"&gt;Content 3&lt;/div&gt; &lt;div class="tab_content" id="tab_4"&gt;Content 4&lt;/div&gt; &lt;div class="tab_content" id="tab_5"&gt;Content 5&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>This uses the following Jquery to make the tabs work:</p> <pre><code>$(document).ready(function() { //When page loads... $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); </code></pre> <p>Is there any way the above javascript can be added to/adapted so that the corresponding image tab is displayed when a content tab is displayed ie: tab_1 and image_1 etc. ?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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