JSFiddle - React, Tailwind, and code Playground

by Spencer Smith

HTML

<div class="item"></div>
<div class="item"></div>
<div class="item"></div>//Need to target this
<div class="item"></div>//Need to target this
<div class="item"></div>//Need to target this
<div class="item"></div>//Need to target this
<div class="item"></div>//Need to target this
<div class="item start"></div>//starting point
<div class="item"></div>

CSS

.good:before{
  content: "";
  float: left;
  background-color: coral;
  width: 15px;
  height: 15px;
  margin-right: 5px;
}

JavaScript

var startIndex = $('.start').index();
var endIndex = startIndex - 5;

for(var i = startIndex - 1; i >= endIndex; i--){
	$('.item').eq(i).addClass("good");
}