1if ($( "#foo" ).hasClass('className')) {
2 $( "#foo" ).removeClass( 'className');
3} else {
4 $( "#foo" ).addClass( 'className');
5}
1$('some_element').addClass('some-class');
2
3// You can add more than one class at one time
4$('some_element').addClass('some-class another-class yet-another-class');
5
6// Even thought jQuery allows you to do this
7$('some_element').addClass('some-class').addClass('another-class').addClass('yet-another-class');
8
9// That would be really wasteful, think of the planet!
10// But more importantly, your RAM
11// oh and those poor folks who be viewing your website