JSFiddle - React, Tailwind, and code Playground

HTML

<div class="class1"></div>
<div class="class2"></div>

CSS

.class1 {
   background-image : url("http://images.visitcanberra.com.au/images/canberra_hero_image.jpg");
  height:20px;
     border:1px solid #000;
}
.class2 {
 height:20px;
    border:1px solid #000;
}

JavaScript

$(function(){
   arr = ["class1", "class2"];
    arrBgExists=[];
    arr.forEach(function(ele){
      


       // var exists=$('.'+i).css('background-image');
        var img = document.getElementsByClassName(ele)[0];
      
      var   style = img.currentStyle || window.getComputedStyle(img, false);
var exists = style.backgroundImage.slice(4, -1);
        
        
        console.log(exists)
        if(exists){
            arrBgExists.push(ele);
        }
      
    });

console.log('these elements are having background '+arrBgExists);    
})