hide-if-contains-image

hide-if-contains-image

The hide-if-contains-image snippet hides any HTML element (or its ancestors) that match a CSS selector if the element background image matches a given pattern.

Parameters

Name

Description

Mandatory

search

The pattern (hex representation) to look for in background images. Enclose in / for regex.

Yes

selector

The CSS selector that an HTML element must match to be hidden.

Yes

searchSelector

CSS selector for elements containing the pattern. Defaults to selector.

No

Filter examples

Filter

Result

hide-if-contains-image ffd8ffe1001845 div

Hides any div whose background-image hex matches the pattern.

hide-if-contains-image /^ffd8ffe1001845/ div

Hides any div whose background-image hex matches the regex.

hide-if-contains-image ffd8ffe1001845 .container div

Hides .container that has a matching div background-image.