setTimeout

by uto usui

HTML

<h1 class="js-late">wait</h1>

SCSS

.js-late {
  width: 100vw;
  height: 100vh;
  justify-content: center;
  align-items: center;
  display: flex;
  //
  &.active {
    background-color: red;
  }
}

JavaScript

const addClass = (className, text) => {

  $('.js-late').addClass(className).text(text);

};

const arg = ['active', 'One second later'];

setTimeout(addClass, 1000, ...arg);