JSFiddle - React, Tailwind, and code Playground

HTML

<!--
Well, yes, I have a section in my main content div. I want to style each .left class which is directly preceded by another .left class, which, in turn, has an img child beneath it in the tree.
-->

<div id="content">
    <section>
        <div class="left"></div>
        <div class="left"></div>
        <div class="left">
            <img />
        </div>
        <div class="left"></div>
        <div class="left"></div>
        <div class="left"></div>
        <div class="left"></div>
        <div class="left"></div>
        <div class="left">
            <img />
        </div>
    </section>
</div>

CSS

#content{
   background: #ccc;
   padding: 24px;
}

.left {
    width: 50px;
    height: 50px;
    margin: 5px;
    background: #fff;

}
.found {
    background: red;    
}

JavaScript

jQuery('#content section .left').each(function(){
    if($(this).prev().hasClass('left') && $(this).has('img').length){
        // DO STUFF HERE
        $(this).addClass('found');
    }
})