JSFiddle - React, Tailwind, and code Playground

by Adam Kinnucane

HTML

<div class="hello">
  <div class="world">
      not empty
  </div>
</div>

<div class="hello">
</div>

<div class="hello">
</div>

<div class="hello">
</div>

<div class="hello">
  <div class="world">
      not empty
  </div>
</div>

<div class="hello">
  <div class="world">
      not empty
  </div>
</div>

<div class="hello">
  <div class="world">
      not empty
  </div>
</div>

CSS

.hello .world {
  padding: 20px;
}

JavaScript

function checkForDiv() {
  var i;
  for (i = 0; i < $(".hello").length; i++) { 
      if (!$(".hello .world")) {
      	$(".hello").html("hey there");
      }
  }
}

checkForDiv();