<!-- focus, blurイベント -->
<div class="event">
  <h1 class="event_title">focus, blur</h1>
  <label for="focusblur_label" class="focusblur_label" id="focusblur_label">
    name
    <input type="text" class="focusblur">
    <input type="text" class="focusblur">
  </label>
</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;
}

/* focus, blurイベント */
.focusblur_label{
  display: flex;
  align-items: center;
  font-size: 1.8rem;
  font-weight: bold;
  width: 400px;
  margin: 60px auto 100px;
}

.focusblur{
  background: #fff;
  border: 2px solid #222;
  width: 150px;
  padding: 1rem;
  margin-left: 1rem;
}

.focusblur.active{
  border: 2px solid #fabe00;
}
//focus, blurイベント
$('.focusblur').on('focus', function(){
  //activeクラスを追加する
  $(this).addClass('active');
});
$('.focusblur').on('blur', 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