I want to change the color of a
when it is clicked by a mouse or while pressing the enter key.<
Please try following code
$('.button').keypress(function(e){ if(e.which == 13){ $(this).css('background-color','#FFF'); } }); $('.button').keyup(function(e){ if(e.which == 13){ $(this).css('background-color',''); } });