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.
2
  • sorry where is the #expand div? Commented Dec 15, 2011 at 16:59
  • you should view the topic and use toggle visibility (javascript function) to change display none settings: stackoverflow.com/a/15636682/2131877 Commented Mar 26, 2013 at 12:09

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.