back to Overview

$$()

Returns a DOM object containing the first match of the given selector, or undefined if no match was found.
Web module only.

Syntax Variants

$(selector)
$(selector, context)
$(selector, context, childOnly)

Parameters

selector
a simple, CSS-like selector for the element. Uses the same syntax as $(). The most common parameter for this function is the id selector with the syntax "#id".
context (optional)
an optional selector, node or list of nodes which specifies one or more common ancestor nodes for the selection. The context can be specified as a selector, a list or using a single object, just like the first argument. The returned list will contain only descendants of the context nodes. All others will be filtered out.
childOnly (optional)
if set, only direct children of the context nodes are included in the list. Children of children will be filtered out. If omitted or not true, all descendants of the context will be included.
(return value)
a DOM object of the first match, or undefined if the selector did not return at least one match

Description

Returns a DOM object containing the first match of the given selector, or undefined if no match was found. $$ allows you to easily access an element directly. It is the equivalent to writing $(selector)[0].

Please note that the function $$ will not be automatically exported by Minified. You should always import it using the recommended import statement:

var MINI = require('minified'), $ = MINI.$, $$ = MINI.$$, EE = MINI.EE;

Example

Select the checkbox 'myCheckbox':

$$('#myCheckbox').checked = true;

See also..

  • $() creates a list using the selector, instead of returning only the first result.

Comments

comments powered by Disqus

back to Overview

Functions