JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
  <div class="inner">
    <div class="field">
    This div exist, so .append should not add a new div, should add only if this div does not exist.
    </div>
  </div>
</div>

JavaScript

if( $("div.container div.inner div.field").length ){
    $("div.container div.inner").append("<div>But for some reason it still adds it.</div>");
}