Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

$(this).siblings(".article").removeClass("current"); or $('.article').removeClass('current');

//these both appear to do the same thing

var main = function(){
  $(".article").click(function(){
//this makes more sense to me because 
//it removes the class from everything EXCEPT 
//the element we are going to apply it to.
    $(this).siblings(".article").removeClass("current");//removeClass from siblings
    $(".description").hide();
    $(this).addClass("current"); // add class to selected element
    $(this).children(".description").show();
  });
}

$(document).ready(main);

//..............................................................................................................................

var main = function() {
  $('.article').click(function() {
//this does the same thing but it removes the class from 
//ALL the elements
//and then adds it back in on the clicked element
    $('.article').removeClass('current'); // removeClass from all
    $('.description').hide();
    $(this).addClass('current'); // add class back in
    $(this).children('.description').show();
  });
}
$(document).ready(main);