Flamingo.Selector.test()

The test() method returns TRUE if the node specified by the CSS selector exists on the current page and FALSE otherwise.

Syntax

Flamingo.Selector.test(selector, parent)

Parameters

Parameter Type Description
selector String CSS selector.
parent Node object Context node against which the specified CSS selector will be executed.

Return Value

Type Description
Boolean TRUE if node is found by the CSS selector or FALSE otherwise.

Example

The example below demonstrates how to check if H1 element exists on page.

Source HTML code available on your original desktop site page:

<html>
 <body>
   <h1>Hello World!</h1>
 </body>
</html>

You need to add the following code to your template to check if the H1 element exists on your page, return it or tell that it is not available:

<!--{if Flamingo.Selector.test('h1') }-->
 Page title is: <!--{= Flamingo.Selector.value('h1') }-->
<!--{else}-->
 There is no page title.
<!--{/if}-->

The result for sample source HTML will look like:

Page title is: Hello World!