Supported: Internet Explorer 6+ Supported: Mozilla Firefox 2+ Supported: Apple Safari 3+ Supported: Google Chrome Supported: Opera 9+ Supported: Konqueror

Utility Functions And Objects

Functions

$

Takes a string as an argument. If passed not a string returns passed value otherwise trying to find elements having “id” equal passed value. When passed more then one argument it’s trying to find all passed objects recursievly then returns an array of found elements.
Usage:

$('divbox');   // -> returns HTMLElement Object having id="divbox"
$('r1', 'r2'); // -> returns an Array of HTMLElement items having specified ids

This functions rewrites declared previously functions $, but put them into _$ holder. If you need to toggle between these functions you can use Ajax.Toggle method. Native $ function from AJAX.OOP package has special property “vendor” ($.vendor) which holds the name of a library. For AJAX.OOP this name is “AJAX.OOP”.


$$

Wrapper function to document.getElementsByTagName, works in a style of $ function. Allows to pass a couple of arguments if needed.

$$('div');      // returns collection of HTMLElements 'div'
$$('div', 'p'); // returns collection of HTMLElements 'div' and 'p'

If this function defined before AJAX.OOP included - will be used previously declared function. In this case learn the function vendor’s documentation.


$a, $A

Converts passed argument to Array type. If passed argument can not be converted to Array returns passed value without modifications.
Example:

// inside function body:
var args = $a( arguments); // <- converts arguments Object to an Array


$w, $W

Splits given string into chunks treating all spaces. This could be useful when you need to represent an array as string.
Example:

alert( $w( 'foo bar'));

Objects

$b, $B

Gives direct access to a document.body Element. $b = $B - them are aliases of the same, so you can use both anywhere you wish:

alert( $b.tagName);
$B.appendChild( element);


$d, $D

This entry is an alias to document Object. $d = $D - them are aliases of the same, so you can use both anywhere you wish:

$d.getElementById( id);
$D.createElement( 'a');


$n, $N

$n = $N and them are aliases to navigator Object. This entry also contains extended property “ua” -> $n.ua, which contains navigator.userAgent string converted to lower case. Usage like following:

document.write( $n.userAgent);
alert( $N.ua.has( 'msie') ? "It's Internet Explorer!" ? "It's another browser");