jQuery addClass example

Change class name on click in jQuery

by joshmoto

HTML

<div class="clock">
  <div class="h1">
    <div>
      <time class="t-01"></time>
      <time class="t-02"></time>
            <time class="t-02"></time>
                  <time class="t-02"></time>
                        <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>      <time class="t-02"></time>
    </div>
  </div>
</div>

SCSS

.clock {
  padding: 40px;
  .h-1,
  .h-2,
  .m-1,
  .m-2 {
    width: 50%;
    float: left;
    position: relative;
    &:before {
      content: "";
      padding-top: 150%;
      display: block;
    }
    >DIV {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
  }
  TIME {
    float: left;
    width: calc(100%/4);
    height: calc(100%/6);
    display: block;
    background: #eeeeee;
    border-radius: 50%;
    position: relative;
    &:before,
    &:after {
      border-radius: 1%;
      content: "";
      display: block;
      width: 2px;
      height: 50%;
      background: #424242;
      left: 50%;
      position: absolute;
      transform: translateX(-1px);
      transform-origin: center bottom;
    }
  }
}

// rotate
@mixin rotate ($deg) {
 transform: rotate(#{$deg}deg);
}

.n-1 {
  .t-01 {
    &:before {
      /* minute */
      @include transform(15);
    }
    &:after {
      /* minute */
      @include transform(30);
    }
  }
  .t-02 {
    &:before {
      /* minute */
      transform: rotate(180deg);
    }
    &:after {
      /* minute */
      transform: rotate(90deg);
    }
  }
}