Query Plugin

Back to plugins | Download plugin

The Query plugin uses the Sizzle CSS selector engine, the same used in the core of the jQuery library.

Query the DOM

The query() method searches for a group of elements based on a CSS selector. The method accepts 2 arguments in the following order:

  nano.query('#example DIV.test');

The query() method returns an Array of nodes, even if only a single node is found, wrapped in the API. Additionally, the returned Array has 4 methods to access the selected nodes: add(), each(), first() and last().

The add() method allows you to perform another search, adding the nodes found to the initial result. This method accepts the same arguments as the query() method.

  nano.query('DIV > SPAN.message').add('IMG.special');

The each() method allows you to iterate over the nodes found by the query. This method accepts 2 arguments in the following order:

  nano.query('IMG.offer, IMG.special').each(function() { this.style({borderColor: 'green'}); });

Finally, the first() and last() methods return the first or the last node in the Array respectively.

For more information regarding CSS selectors visit the Sizzle Wiki or see CSS3 Selectors.

CodeMessageLineFile
2session_start(): open(/var/cpanel/php/sessions/ea-php82/sess_694409adb36a8d53c0c88fb79d6ed0b4, O_RDWR) failed: No such file or directory (2)67/home2/njsorg/public_html/pagetype/cms.php
2session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/ea-php82)67/home2/njsorg/public_html/pagetype/cms.php
8192Creation of dynamic property PageTypeCMS::$html is deprecated43/home2/njsorg/public_html/pagetype/plugins/html/pagetype.plugin.php