jQuery addClass example

Change class name on click in jQuery

by Chuck Tornton

HTML

<script src="https://kit.fontawesome.com/dbaffbfc92.js"></script>
<!-- <ul class="menu">
  <li>Посмотреть все
    <ul class="submenu">
      <li>подпункт 1</li>
      <li>подпункт 2</li>
      <li>подпункт 3</li>
      <li>подпункт 1</li>
      <li>подпункт 2</li>
      <li>подпункт 3</li>
      <li>подпункт 1</li>
      <li>подпункт 2</li>
      <li>подпункт 3</li>
      <li>подпункт 1</li>
      <li>подпункт 2</li>
      <li>подпункт 3</li>
      <li>подпункт 3</li>
    </ul>
  </li>
  </ul> -->
  
<div class="items">
  <div class="hiddenInfo">
    <div class="hiddenInfoBlock">
      <h3>Шо-то там про гантельки</h3>
      <button class="buttonShow">
        Смотреть
      </button>
      <div class="activity">
        <div class="carouselLikes"><i class="far fa-heart"></i><span> - 445</span></div>
        <div class="carouselComments"><i class="far fa-comment"></i><span> - 12</span></div>
      </div>
    </div>
  </div>
  <img src="https://aniraccoon.com/uploads/posts/2019-08/1564779938_083324a0772dd5ab549c0351cd088751.jpg" alt="">
</div>

CSS

:root {
  --reds-color: #e84848;
}

html, body {
  background: #ffffff;
  margin: 0;
  padding: 0px;
  font-family: Helvetica;
  display: flex;
  align-items: center;
  justify-content: center;
  
}

.menu {
    list-style-type: none;
    cursor: pointer;
}

ul.submenu {
  position: absolute;
  display: none;
  max-width: 415px;
  list-style-type: none;
}

ul.menu>li:hover ul.submenu {
  display: flex;
  flex-wrap: wrap;
  background: black;
  color: #fff;
  padding: 30px 30px;
}

.submenu li {

  height: 20px;
  margin-right: 20px;
  border-bottom: 3px solid darkred;
}

.submenu li:hover {
  border-bottom: 3px solid #fff;
  cursor: pointer;
}

.items {
  height: 300px;
  width: 212px;
/*   border: 4px solid black; */
  margin: 0;
  padding: 0;
  position: relative;
}

.items img {
  height: 300px;
  width: 212px;
}

.items img:hover {
  display: block;
  cursor: pointer;
}

.hiddenInfo {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  top: 0;
  background: #00000069;
  height: 100%;
  width: 100%;
  display: none;
  color: #fff;
}

.items:hover .hiddenInfo{
  display: block;
  cursor: pointer;
}

.hiddenInfo h3 {
  text-align: center;
}

.hiddenInfoBlock {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.buttonShow {
  background: var(--reds-color);
  border: none;
  height: 30px;
  width: 90px;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
}

.activity {
  margin-top: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}