JSFiddle - React, Tailwind, and code Playground

by Andres Abadia

HTML

<div class="par">
    
    <div class="red">
      helli
    </div>
  </div>

CSS

.par{
  background-color:red;
}

.par{
  background-color:yellow;
}

.par{
  width:200px;
  height:200px;
  border:1px solid blue;
  
}


.red{
  width:100px;
  height:100px;
  color:red;
  border:1px solid;
  background-color:green
}

JavaScript

var redElements = document.querySelectorAll(".red");
for(var i=0;i<redElements.length;i++){
  redElements[i].parentElement.style.backgroundColor="red";
}