Target elements with inline styles

To target an element in JavaScript that has certain inline styles, you can use the following code:

var elem = document.querySelector('h1[style*="color: red;"]');

The value of elem will now be the first H1 on the page that has a style attribute with a value that includes color: red;

The use of style*= allows for other inline styles to be present, otherwise the query would have to match the exact value of the style attribute.