if( this.style.backgroundColor == 'white'){ $(this).toggleClass("btn"); } else { $(this).toggleClass("btn2"); }