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:
- How can i toggle display block and none on click with this html?
- 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.
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:
- How can i toggle display block and none on click with this html?
- 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.
- sorry where is the #expand div? – microspino Commented Dec 15, 2011 at 16:59
- you should view the topic and use toggle visibility (javascript function) to change display none settings: stackoverflow./a/15636682/2131877 – T.Todua Commented Mar 26, 2013 at 12:09
1 Answer
Reset to default 4http://jsfiddle/F5NCt/1/
<head>
<script src="//ajax.googleapis./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.
also see the example above
hope it helps you