<!-- mousedown, mouseupイベント -->
<div class="event">
  <h1 class="event_title">mousedown, mouseup</h1>
  <button type="button" name="button" class="button_downup">click 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;
}

/* mousedown, mouseupイベント */
.button_downup{
  width: 200px;
  margin: 60px auto 100px;
  background: #eee;
  padding: 1.5rem 0;
  border-radius: 10px;
  font-size: 1.8rem;
  font-weight: bold;
}
// mousedown, mouseupイベント
$('.button_downup').on('mousedown', function(){
    //ボタンのテキストをmousedownに変更
    $(this).text('mousedown');
    //ボタンの色を黒に変更
    $(this).css({
      'background' : '#222',
      'color' : '#fff'
    });
  });
  $('.button_downup').on('mouseup', function(){
    //ボタンのテキストをmouseupに変更
    $(this).text('mouseup');
    //ボタンの色を赤に変更
    $(this).css({
      'background' : '#cd0505',
      'color' : '#fff'
    });
  });
  $('.button_downup').on('mouseleave', function(){
    //ボタンのテキストをclick meに変更
    $(this).text('click me');
    //ボタンの色を元のグレーに変更
    $(this).css({
      'background' : '#eee',
      'color' : '#222'
    });
  });

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