Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery show / hide div on click?
    primarykey
    data
    text
    <p>I'm trying to use jquery to show and hide a div onclick, and, although I'm not getting any errors, it's not showing or hiding anything either. </p> <p>**EDIT - UPDATED **</p> <pre><code>$(document).ready(function() { $("#nav-inner a").click(function() { var type = $(this).attr("class"); $("div.v1 &gt; div").not("." + type).stop().hide().end().filter("." + type).stop().show(); return false; }); </code></pre> <p>});</p> <p>Here's the jquery: </p> <pre><code>$(document).ready(function() { if($("#nav-inner")) { $("#nav-inner ul li a").click(function(evt) { var type = $(this).attr("class"); var rowcount = 0; $('div.v1 .vc').each(function(idx,el) { if(type == 'typea') { if($(el).hasClass('typea')) { $(el).show(); } else { $(el).hide(); } } }); }); } }); </code></pre> <p>And here's the markup: </p> <pre><code>&lt;div id="page"&gt; &lt;div id="header"&gt; &lt;div id="nav"&gt; &lt;div id="nav-inner"&gt; &lt;ul class="nav-inner-li"&gt; &lt;li&gt; &lt;a class="typea" href="#"&gt;&lt;img src="/images/typea.png"&gt;&lt;/a&gt; &lt;a class="typea" href="#"&gt;Type A&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="content"&gt; &lt;div id="content-content"&gt; &lt;div id="content-left"&gt; &lt;div class="v1"&gt; &lt;div class="vc"&gt; &lt;div class="typea"&gt; &lt;div class="title"&gt; Title &lt;/div&gt; &lt;div class="body"&gt; Body &lt;/div&gt; &lt;/div&gt; &lt;div class="typeb"&gt; &lt;div class="title"&gt; Title 2 &lt;/div&gt; &lt;div class="body"&gt; Body 2 &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &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