Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery core tabs script - multiple instances?
    primarykey
    data
    text
    <p>I have the following jQuery script on my site to switch tabs without reloading the page. I'm using jQuery core v1.3.2 (NOT jQuery UI)</p> <pre><code>&lt;!-- JS --&gt; &lt;script type="text/javascript"&gt; $(function() { var tabify = function () { var id = $('#content &gt; div').hide().attr('aria-hidden', 'true').filter(window.location.hash || ':first').show().attr('aria-hidden', 'false').attr('id'); $('#content &gt; ul &gt; li').removeClass('selected').find('a[href=#' + id + ']').parent().addClass('selected'); } setInterval(tabify, 100); tabify(); }); &lt;/script&gt; &lt;!-- HTML --&gt; &lt;div id="content"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#blog" role="tab"&gt;Blog&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#videos" role="tab"&gt;Videos&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#photos" role="tab"&gt;Photos&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="blog" role="tabpanel" aria-labelledby="tab1" aria-hidden="false"&gt;Blog Content&lt;/div&gt; &lt;div id="videos" role="tabpanel" aria-labelledby="tab2" aria-hidden="true"&gt;Videos Content&lt;/div&gt; &lt;div id="photos" role="tabpanel" aria-labelledby="tab3" aria-hidden="true"&gt;Photos Content&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I want to add another instance of this script on the same page, but just copy/pasting this with different variable names doesn't work. Any ideas?</p> <p><strong>EDIT:</strong> Here is my HTML and JS for the second instance. The problem is when I click on a tab in the second instance, it hides all the content divs in the first instance, and vice versa. I want them to be independent of one another.</p> <pre><code>&lt;!-- JS --&gt; &lt;script type="text/javascript"&gt; $(function() { var tabifyplayer = function () { var idplayer = $('#discography &gt; div').hide().attr('aria-hidden', 'true').filter(window.location.hash || ':first').show().attr('aria-hidden', 'false').attr('idplayer'); $('#discography &gt; ul &gt; li').removeClass('selected').find('a[href=#' + idplayer + ']').parent().addClass('selected'); } setInterval(tabifyplayer, 100); tabifyplayer(); }); &lt;/script&gt; &lt;!-- HTML --&gt; &lt;div id="discography"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#cor-player" role="tab"&gt;Chance of Rain (2009)&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#debutcd-player" role="tab"&gt;Debut CD (2007)&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="cor-player" role="tabpanel" aria-labelledby="tab1" aria-hidden="false"&gt;Content Goes Here&lt;/div&gt; &lt;div id="debutcd-player" role="tabpanel" aria-labelledby="tab2" aria-hidden="true"&gt;Content Goes Here&lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    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.
 

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