views:

74

answers:

2

I previously got this (useful!) answer about using .next() for same DIV blind effect.

However, I can't seem to get this simple function to work for more than one DIV at the same time:

$(document).ready(function(){
 $("#closeButton").click(function (){
 $(this).next().toggle("fast");
 });
});

Any ideas? Thanks.

+2  A: 

The selector you are using is only selecting one element. You would need to change is to it selected a collection of elements.

$(document).ready(function(){
        $(".wider_div h3").click(function (){
        $(this).next().toggle("fast");
        });
});

This might work given the structure.

MacAnthony
Perfect. Thank you.
konzepz
+1  A: 

Is it about a specific type of button that occurs multiple times on a page? Try using jQuery's live():

$(document.ready(function() {
    $('button.your_class').live('click', function (){
        $(this).toggle('fast');
    });
});

and attach the appropriate class to the buttons you want to 'be listened'.

JorenB
+1 live is the way forward
redsquare