Change color of button during keypress

后端 未结 3 740
终归单人心
终归单人心 2021-01-24 21:49

I want to change the color of a


when it is clicked by a mouse or while pressing the enter key.<

3条回答
  •  终归单人心
    2021-01-24 22:24

    Try This

    .clicked{
    background:#fff !important;
    }
    
    $('.button').keydown(function(e){
          if(e.which == 13){
               $(this).addClass('clicked');
            }
     e.preventDefault();
      });
    

提交回复
热议问题