Note that there are some explanatory texts on larger screens.

plurals
  1. POSwitching Between Hidden Divs on Page with Same Class Affects All Divs
    primarykey
    data
    text
    <p>I have 2 div's on my page with individual id's. Within those div's I have an unordered list that shares the same class (.stats-nav):</p> <pre><code>&lt;div id="product1"&gt; &lt;ul class="stats-nav"&gt; &lt;li class="stat-cat1"&gt;&lt;a href=""&gt;Ingredients&lt;/a&gt;&lt;/li&gt; &lt;li class="stat-cat2"&gt;&lt;a href=""&gt;Nutrition Info&lt;/a&gt;&lt;/li&gt; &lt;li class="stat-cat3"&gt;&lt;a href=""&gt;Feeding Instructions&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!--end product1--&gt; &lt;div id="product2"&gt; &lt;ul class="stats-nav"&gt; &lt;li class="stat-cat1"&gt;&lt;a href=""&gt;Ingredients&lt;/a&gt;&lt;/li&gt; &lt;li class="stat-cat2"&gt;&lt;a href=""&gt;Nutrition Info&lt;/a&gt;&lt;/li&gt; &lt;li class="stat-cat3"&gt;&lt;a href=""&gt;Feeding Instructions&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!--end product2--&gt; </code></pre> <p>Only 1 of the divs are show at a time; the other is hidden (show/hide). The same is true for the list items: only one is shown at a time. The default state is "Ingredients".</p> <p>I'm using Jquery's live to bind it:</p> <pre><code>$("li.stat-cat1 a").live('click', function() { $(".nutritional-info").show(); return false; }); </code></pre> <p>The problem I am having is if I'm looking at #product2 and click on say "Nutritional Info" and then click over to #product1, it will show #product1's correct info but it will start where I left off at "Nutritional Info" rather than the default state "Ingredients".</p> <p>Is there a way for me to "clear" the last state of the div?</p> <p>(If I load it in via ajax .load the content refreshes as intended but I no longer wish to use the ajax method).</p> <p>Thanks!</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