Link to home
Start Free TrialLog in
Avatar of xill2678
xill2678

asked on

jQuery expand/collapse

i have a code snippet i picked up from somewhere (i can't remember where now) but i'd like to add a simple fading effect to it. this snippet uses jQuery's slideToggle function to simply expand & contract a div. I'd like to also add jQuery's fading function to this, but i havent been able to figure out how (i'm new to this stuff). I'd like the div to fade in when expanding, and fade out when contracting. can anyone give me any pointers on this? thanks
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript">
$(function(){
$("#trigger").click(function(event) {event.preventDefault();$("#hidden").slideToggle();});
});
</script>
 
 
<a href="# id="trigger">expand/contract div below</a>
 
<div id="hidden" style="display:none;">
     content to fade here
</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Albert Van Halen
Albert Van Halen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xill2678
xill2678

ASKER

im still learning jquery and everything it has built in, but the animate function you provided is exactly what i was looking for! funnily enough other plugins i ran across took 50+ lines of code even with jquery as a base. this is sweet and simple and does just what i need it to without all the fluff or useless options. thank you so much! :)