hide-if-contains

hide-if-contains

The hide-if-contains snippet hides any HTML element (or its ancestors) that match a CSS selector if the element's text contains a given string.

Parameters

Name

Description

Mandatory

search

The text string to locate. Enclose in / for regex.

Yes

selector

CSS selector identifying which elements to hide.

Yes

searchSelector

CSS selector for locating the search text. Defaults to selector.

No

Filter examples

Filter

Result

hide-if-contains FAQ nav

Hides any nav element containing "FAQ" anywhere in its subtree.

hide-if-contains FAQ nav a

Hides nav elements that have anchor tags with "FAQ" text.

hide-if-contains /.*/ li.serp-item 'li.serp-item div.label'

Hides list items with matching label content using regex.