Chapter.5JavaScript(jQuery)入門

09応用問題(答え無し)

イベント発生させる要素(と操作したい要素)のID名 #chapter-5-9-btn
追加または削除するクラス名 .active

-- js --
$(function(){
  $('#chapter5-9-btn').click(function(){
    $(this).toggleClass('active');
  });
});

-- css --
.group::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 20px;
  width: 10px;
  height: 10px;
  border-top: 2px solid #000;
  border-right: 2px solid #000;
  transform: rotate(-45deg) translateY(-50%);
}
.group.active::before {
  border-top: none;
  border-right: none;
  border-bottom: 2px solid #000;
  border-left: 2px solid #000;
}