Class $
The libmacrame namespace.
Defined in: core.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
$(selector, context)
The $ symbol is simply an alias of libmacrame, for quicker access to
the main namespace and main function, which is $.init.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
$.extend(overwrite, destination, source)
This function extends objects.
|
| <static> |
$.init(selector, context)
Find DOM elements.
|
Class Detail
$(selector, context)
The $ symbol is simply an alias of libmacrame, for quicker access to
the main namespace and main function, which is $.init.
- Parameters:
- {String} selector
- {Document|Element} context Optional, Default: document
- See:
- libmacrame
- $.init This is the function called when you call $()
Method Detail
<static>
$.extend(overwrite, destination, source)
This function extends objects.
var obj1 = {a: 'a1', b: 'b1', d: 'd1'}, obj2 = {a: 'a2', b: 'b2', c: 'c2'}; $.extend(obj1, obj2);// Now obj1.c == 'c2', while obj1.a, obj1.b // and obj1.d remain the same. // If$.extend(true, obj1, obj2)is // called, then obj1.a, obj1.b, obj1.c // become all the same as in obj2.
var obj1 = {a: 'a1', b: 'b1', extend: $.extend};
obj1.extend({c: 'c1', d: 'd1'});
// In this case the destination object which is to be extend is
// obj1.
- Parameters:
- {Boolean} overwrite Optional, Default: false
- If the first argument is a boolean, then it will be considered as a boolean flag for overwriting (or not) any existing methods and properties in the destination object. Thus, any method and property from the source object will take over those in the destination. The argument is optional, and if it's omitted, then no method/property will be overwritten.
- {Object} destination Optional, Default: this
- The second argument is the optional destination object: the object which will be extended. By default, the this object will be extended.
- {Object} source
- The third argument must provide list of methods and properties which will be added to the destination object.
<static>
{Element|NodeList}
$.init(selector, context)
Find DOM elements.
This function currently allows you to use CSS selectors to find the DOM elements you want.
TODO: This is not done yet.
// Find the element with id='foo':
$('#foo');
// Find the elements having a class token 'foo':
$('.foo');
// Find all the<span>elements which are direct child // children of<p>elements:$('p > span');
- Parameters:
- {String} selector
- The CSS selector. You can also use multiple selectors, separated by comma. Basically, you can use anything supported by querySelectorAll().
- {Document|Element} context Optional, Default: document
- The context where the CSS selector will be used for finding the matching elements.
- Returns:
- {Element|NodeList} The element found, or the list of elements matching the selector.
- Requires:
- A Web browser which implements Selectors API. Currently this means Opera 10+, Firefox 3.1+ and Safari 4+.