Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery expand and collapse functionality
    primarykey
    data
    text
    <p>I'm new to Jquery/javascript and I have myself a bunch of levels of links that I need to organize in to lists that are expandable and collapsible via a +/- button.</p> <p>An example of the information I am working with is:</p> <pre><code>Category1 (Level 1) - Subcategory 1 (Level 2) - Subcategory 2 - Subcategory 3 Category2 (Level 1) - Subcategory 1 (Level 2) - Subcategory 2 - Subcategory 3 Category3 (Level 1) - Subcategory 1 (Level 2) ----Subcategory 1 (Level 3) - Subcategory 2 - Subcategory 3 </code></pre> <p>Code wise, it looks like this:</p> <pre><code>&lt;div class="navCol"&gt; &lt;h4&gt;Pet Club&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="/pc/home"&gt;Pet Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/pc/articles"&gt;Arts&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/pc/coupons"&gt;ns&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/pc/pet-prescriptions"&gt;Pet Prescrions&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="navCol"&gt; &lt;h4&gt;Fresh Ideas&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="/fi/cooking-guide"&gt;Know Yur Food&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/fi/departments"&gt;Depaments&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/fi/gluten-free"&gt;Free&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/fi/house-of-bbq"&gt;HoBQ&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/fi/how-to-shop"&gt;rt&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/fi/kids-cooking-club"&gt;Kidsb&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/fi/price-chopper-products"&gt;Tr&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="navCol"&gt; &lt;h4&gt;vings&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="/vings/advantedge-card"&gt;w&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/baby-club"&gt;Bb&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/blue-rhino"&gt;asdf&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/grocery-apps"&gt;On &lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/grocery-coupons"&gt;C&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/grocery-offers"&gt;Em&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/grocery-sweepstakes"&gt;P&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/meal-deals"&gt;W&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/pc"&gt;Pet&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/price-chopper-fuel-advantedge"&gt;Fuel&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/school-vings-program"&gt;School&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/vings/weekly-flyer"&gt;Weekly&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I want to be able to click the category +- and it will show/hide all the links underneath it. Same with subcategory1 in category3 where I am dealing with the third level. How would I be able to implement all the way down to level 3?</p> <p>Should I precede all my links with L1, L2, L3 tags? I have looked at some questions that deal with the +/- sign and implementation but I do not understand a lot of it.</p> <p>Also, how would I go about implementing a button that shows all or expands all on toggle? That is, it would expand to the deepest levels and collapse back to show only the level 1 categories.</p> <p>If you any place where I can start to learn this on my own, that would be greatly appreciated as well. This is my first project and I am confused as to where to start.</p>
    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.
    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