Selecting specified div when clicking it
Hi,
I am trying to make a functional dynamic jquery selection but it seems impossible for me.
Here is the code:
- $('.schools').eq(0).toggle(function(){
- $('.big_schools').eq(0).fadeIn('slow');
- $('.big_schools').eq(1).fadeOut('slow');
- $('.big_schools').eq(2).fadeOut('slow');
- }, function(){
- $('.big_schools').eq(0).fadeOut('slow');
- });
- $('.schools').eq(1).toggle(function(){
- $('.big_schools').eq(1).fadeIn('slow');
- $('.big_schools').eq(0).fadeOut('slow');
- $('.big_schools').eq(2).fadeOut('slow');
- }, function(){
- $('.big_schools').eq(1).fadeOut('slow');
- });
- $('.schools').eq(2).toggle(function(){
- $('.big_schools').eq(2).fadeIn('slow');
- $('.big_schools').eq(1).fadeOut('slow');
- $('.big_schools').eq(0).fadeOut('slow');
- }, function(){
- $('.big_schools').eq(2).fadeOut('slow');
- });
This code can make the user click on div 0 and open another div below it. Then if you click on div 1, it should close the div below div 0 and open the div below div 1. The same for 2. How can I make this in a dynamic way, cuz like this I have to write down all possibilities.
This works for three divs. How can I make this work in a dynamic way?
Pls help!