JSFiddle - React, Tailwind, and code Playground

by skodnik

HTML

<div id="sidebar">
  <p>
    Какой-либо текст
  </p>
</div>

CSS

#sidebar {
  width: 200px;
  height: 200px;
  background: url(http://lorempixel.com/400/200/);
}

JavaScript

var imgsidebar = [
    'http://lorempixel.com/400/200/',
    'http://lorempixel.com/400/200/',
    'http://lorempixel.com/400/200/sports/',
  ],
  i = 1;

function bgsidebar() {
  if (i > (imgsidebar.length - 1)) {
      i = 1;
      $('#sidebar').css({'background': 'url(' + imgsidebar[0] + ')'});
  } else {
      $('#sidebar').css({'background': 'url(' + imgsidebar[i] + ')'});
      i++;
  }
}
var intervalCsaHead = setInterval(bgsidebar, 6000);