How to I add a class to a div element when it has a 'style' attribute containing variable data?

```
    <div style="background-color: #000;">
    </div>

```

What I want to achieve is a script that automatically adds a class `post-with-bg` to every div element with the above properties.