2 Replies - 1553 Views - Last Post: 07 April 2013 - 01:01 PM

#1 Nublet   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 12-October 12

Making list drop down when I click the heading.

Posted 07 April 2013 - 09:07 AM

Okay, I'm very new to jQuery but a project I'm doing requires me to use it. So I'm thinking of using it so that when the user clicks my list heading the list drops down. Here's the list I have:

Posted Image

So what I'm saying is, when the user clicks "Albums by Big L, alive and posthumous" the list of his albums drops down. I just have no idea how to do it hehe. Any pointers?

Is This A Good Question/Topic? 0
  • +

Replies To: Making list drop down when I click the heading.

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5612
  • View blog
  • Posts: 14,686
  • Joined: 18-April 07

Re: Making list drop down when I click the heading.

Posted 07 April 2013 - 10:24 AM

Put your <UL> tag inside a div. Give the div an ID attribute. In jQuery there is a function called .slideDown() which you can call on the div when a click is detected on the heading. To start it off though, we want to set the menu to be hidden.

<span id="myheading">Albums by Big I, alive and posthumous:</span>
<div id="submenu" style="display: none;">
   <ul>
     <li>Lifestylez ov da Poor & Dangerous, 1995</li>
     ...
   </ul>
</div>



Then jQuery like this can control the slide down...

$(function() {
     $("#myheading").click(function() {
          $("#submenu").slideDown();
     });
});



Here if we click the heading, we say get the element with ID "submenu" and slide it down. So play with that and you will surely get the idea. If you want the menu to go back up when they click the heading again, check out toggle() and slideUp() methods.

P.S. Here is a fiddle to show you... http://jsfiddle.net/CVUxr/


:)

This post has been edited by Martyr2: 07 April 2013 - 10:25 AM

Was This Post Helpful? 0
  • +
  • -

#3 Nublet   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 12-October 12

Re: Making list drop down when I click the heading.

Posted 07 April 2013 - 01:01 PM

Thank you so much! :D/> I've been lost in this thing for weeks :P/>

This post has been edited by Dormilich: 08 April 2013 - 01:15 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1