hide-if-shadow-contains

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

You can use the hide-if-shadow-contains snippet to hide an element based on its shadow's text.

Parameters

NameDescriptionMandatory

search

The string to look for in every HTML element's shadow. If the string begins and ends with a slash (/), the text in between is treated as a regular expression.

Yes

selector

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

Yes

Filter examples

The following table lists examples that use the hide-if-shadow-contains snippet:

FilterResult

hide-if-shadow-contains ads nav

Hides any nav element whose shadow's text content contains the word ads.

hide-if-shadow-contains /^[0-9]+$/ .container

Hides any .container element whose shadow's text matches the /^[0-9]+$/ regular expression. (consists in a number)

Other resources

Last updated