链接加上class="link"就行,不需要JS

.link {
  position: relative;
  padding-bottom: 0;
}
.link:hover {
    color:#fff;
}
.link:not(.child):after {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: -1;
  width: 0;
  height: 22px;
  background-color: #4990E2;
  content: '';
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  -o-transition: all 0.3s ease-in-out;
  -ms-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
}
.link:not(.child):hover:after {
  width: 100%;
}