Could someone explain to me how the following code works? I’ve spent a bit of time trying to understand it, but it’s beyond me. This is my code:
$('.acc_trigger').removeClass('active').next().slideUp();
$(this).toggleClass('active').next().slideDown();
The JSFiddle is here.
Edit
I think so i understand it first it will hide all and show the current one thats selected thanks.
The first part selects all elements with the class
acc_trigger. The second part removes the classactiveon those elements. The third part changes the selector to the next sibling of the selected element, and the fourth part does a slide up animation on that newly selected element.This is roughly the same thing except it uses the current element, most likely from an event, and instead of merely removing the class it toggles it, which will add it if it’s not there and remove it if it is.