<!-- mouseenter, mouseleaveイベント -->
<div class="event">
  <h1 class="event_title">mouseenter, mouseleave</h1>
  <button type="button" name="button" class="button_enterleave">hover me</button>
</div>
html{
  font-size: 62.5%;
  font-family: "Yu Gothic Medium", "游ゴシック Medium", "YuGothic", "游ゴシック体", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro", "メイリオ", "Meiryo", sans-serif;
  letter-spacing: 0.1em;
  color: #222;
}

button, input{
  background-color: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  display: block;
}

.event{
  width: 400px;
  margin: 30px auto;
}

.event_title{
  font-size: 2rem;
  padding: 0.8rem 0 1rem 2rem;
  background: #222;
  color: #fabe00;
  display: block;
}

/* mouseenter, mouseleaveイベント */
.button_enterleave{
  width: 200px;
  margin: 60px auto 100px;
  background: #eee;
  padding: 1.5rem 0;
  border-radius: 10px;
  font-size: 1.8rem;
  font-weight: bold;
}

.button_enterleave.active{
  background: #cd0505;
  color: #fff;
}
// mouseenter, mouseleaveイベント
$('.button_enterleave').on('mouseenter', function(){
  //activeクラスを追加する
  $(this).addClass('active');
});
$('.button_enterleave').on('mouseleave', function(){
  //activeクラスを消去する
  $(this).removeClass('active');
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js