I can't select the .current section
Hello
I'm stuck. I've the following structure:
- <section class="gallery" id="media-home">
- <ul class="list">
- <li class="selected">Photos</li>
- <li>Videos</li>
- <li>Attachments</li>
- <li>New</li>
- </ul>
-
- <section class="gallery-item current">
- ………
- </section>
- <section class="gallery-item">
- ………
- </section>
- <section class="gallery-item">
- ………
- </section>
- <section class="gallery-item">
- FORM
- </section>
- </section>
-
-
- $('.list li').click(function(){
- var which = $(this).parent().parent().attr('id');
- var ide = $(this).index()+1;
- $(this).parent().find('.selected').removeClass();
- $('#'+which+' .gallery-item').find('.current').removeClass(' current '); // <<< HERE IS THE PROBLEM!!
- $('#'+which +' .gallery-item:nth-of-type('+ide+')').addClass('current');
- $(this).addClass('selected');
- });
I don't know why the script doesn't hide the previous current section... I can't use the .gallery-item directly because I have two like this and if I use the class the changes applies in both of them. Does anybody know what could be happen?
Thanks!