There are no tracking or monitoring cookies on this site. There are only cookies used for documentation examples related to cookies.
Close

Processing...
This may take a few seconds.

if-exists

Syntax

if-exists: selector;

This conditional action will return true if the selector is present in the DOM.

selector = The selector you want to check. This can be any valid CSS selector that will return one result. If more than one result is gotten from the selector, the first one will be chosen.

For example, this will return true if the element #myDiv is in the DOM.

@conditional myDivPresent {
    if-exists: #myDiv;
}

When used on an event selector with no parameters in parentheses, it will default to checking "self". Eg. #myDiv:if-exists: ...

if-exists