The O Shortcut


#1

Can somebody please show me in what lesson did it show how to add a class or remove a class????? I have not seen it, so I'm having an issue with the code on this current exercise.

var main = function() {
$('.article').keypress(function(event) {
if(event.which === 111){
$(".current").children(".description").toggle();
}
});
};

$(document).ready(main);


#2

Hi Antimatter,

You can use the jQuery function addClass() to add a class, removeClass() to remove one, and toggleClass() to toggle a class. Pretty simple :wink:
Their usage is like this:

$('element').toggleClass('class-name');
          /* ↑ `addClass()` and `removeClass()` work the same way */

The o shortcut, step 7
#3

thank you very much.