JSFiddle - React, Tailwind, and code Playground

HTML

<div style="background-image: url(foo);" id="_1">
    <div id="_2">
         <div style="background-image:url();" id="_3">text</div>
    <div>
</div>

CSS

div {
  padding: 1em;
  border: dashed 1px gray;
}
div[style^="background-image"] {
  border: dashed 1px red;
}

JavaScript

console.clear()

var withBgProp = document.querySelectorAll('div[style^="background-image"]')

var withFilledBg = Array.prototype.slice.call(withBgProp).filter(
   el => !!el.style.backgroundImage.match(/\("(.+)"\)/)
)
 
console.log(withFilledBg)