0

I have this code: CSS:

 .hiddenlinks{display: none;}

HTML:

<div id="expand">

<a href="javascript://" class="business" >123</a>
    <div class="hiddenlinks">
         <a href="/"target="_blank" class="business" style="color:#f36523">ABC</a><br />
         <a href="/"target="_blank" class="business" style="color:#f36523">DEF</a><br />
         <a href="/"target="_blank" class="business" style="color:#f36523">HIJ</a>
    </div>
 </div>

There is a list of similar div ids in a vertical order. What I am trying to do is once "123" is clicked, the divs id under #expand will shift down and the "ABC", "DEF", and "HIJ" will display:block.

So my question is a two parter:

  1. How can i toggle display block and none on click with this html?
  2. Is there a way to animate the separation of the div id's once .hiddenlinks goes from display:none to display:block. and also when .hiddenlinks goes back to display:none and the div ids close the gap.
James Montagne
  • 77,516
  • 14
  • 110
  • 130
Jean Hules
  • 415
  • 3
  • 6
  • 12

1 Answers1

4

http://jsfiddle.net/F5NCt/1/

<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"><<<< this goes in the header 
</script>
<script>
$(document).ready(function(){
  $(".business").click(function(){
    $(".hiddenlinks").slideToggle();
  });
});
</script>
</head>
<body>

    <div id="expand">

<a href="javascript://" class="business" >123</a>
    <div class="hiddenlinks">
         <a href="/"target="_blank" class="business" style="color:#f36523">ABC</a><br />
         <a href="/"target="_blank" class="business" style="color:#f36523">DEF</a><br />
         <a href="/"target="_blank" class="business" style="color:#f36523">HIJ</a>
    </div>
 </div>
</body>





    .hiddenlinks { 
display:none;
}

i have created a example for you i hope it helps once you click 123 the options drop down to your second question i m not sure but i think if you will have different id divs for each of your hidden link then in .slideToggle(//inside here you can customise how each div is shown\);

please see

www.jquery.com

also see the example above

hope it helps you

user1706511
  • 133
  • 1
  • 7