Trying to dynamically expand different divs with one function

Posted by Matt Nathanson on Stack Overflow See other posts from Stack Overflow or by Matt Nathanson
Published on 2010-06-08T21:11:50Z Indexed on 2010/06/08 21:22 UTC
Read the original article Hit count: 218

Filed under:
|
|
|
|

I'm trying to be able to dynamically expand / collapse multiple divs with the same code....

it's controlled with the click of a span (toggle) and then i'm trying to get the next id(the div that would slide up and down)

            $('span').toggle(
    function() {
$('#albumholder').slideToggle(600);
    $(this).html('-');},
    function() {
$('#albumholder').slideToggle(600);
    $(this).html('+');}

    );

This code works to expand 1 div... but assume i have a divs

#downloadholder
#linksholder
etc...
How can i achieve the same effect with the same code? Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery