1 Native: Window {#Window}
2 ========================
4 The following functions are treated as Window methods.
10 The dollar function has a dual purpose: Getting the element by its id, and making an element in Internet Explorer "grab" all the [Element][] methods.
14 var myElement = $(el);
18 1. el - The Element to be extended. Can be one of the following types:
19 * (*element*) The element will be extended if it is not already.
20 * (*string*) A string containing the id of the DOM element desired.
21 * (*object*) If the object has a toElement method, toElement will be called to get the Element.
25 * (*element*) A DOM element.
26 * (*null*) Null if no matching id was found or if toElement did not return an element.
30 #### Get a DOM Element by ID:
32 var myElement = $('myElement');
34 #### Get a DOM Element by reference:
36 var div = document.getElementById('myElement');
37 div = $(div); //The element with all the Element methods applied.
41 - This method is useful when it's unclear if working with an actual element or an id. It also serves as a shorthand for document.getElementById().
42 - In Internet Explorer, the [Element][] is extended the first time $ is called on it, and all the [Element][] Methods become available.
43 - Browsers with native HTMLElement support, such as Safari, Firefox, and Opera, apply all the [Element][] Methods to every DOM element automatically.
44 - Because MooTools detects if an element needs to be extended or not, this function may be called on the same Element many times with no ill effects.
48 Function: $$ {#dollars}
49 -----------------------
51 Selects and extends DOM elements. Elements arrays returned with $$ will also accept all the [Element][] methods.
55 var myElements = $$(aTag[, anElement[, Elements[, ...]);
59 * Any number of the following as arguments are accepted:
63 * strings as selectors.
67 * (*array*) - An array of all the DOM elements matched, extended with [$][].
71 #### Get Elements by Their Tag Names:
73 $$('a'); //Returns all anchor elements in the page.
74 $$('a', 'b'); //Returns all anchor and bold tags on the page.
76 #### Using CSS Selectors When [Selectors][] is Included:
78 $$('#myElement'); //Returns an array containing only the element with the id 'myElement'.
79 $$('#myElement a.myClass'); //Returns an array of all anchor tags with the class 'myClass' within the DOM element with id 'myElement'.
81 #### More Complex $$ Usage:
83 //Creates an array of all elements and selectors passed as arguments.
84 $$(myelement1, myelement2, 'a', '#myid, #myid2, #myid3', document.getElementsByTagName('div'));
88 - When [Selectors][] is loaded, [$$][] will also accept CSS Selectors. Otherwise, the only selectors supported are tag names.
89 - If an expression doesn't find any elements, an empty array will be returned.
90 - The return type of element methods run through [$$][] is always an array, regardless of the amount of results.
94 - See [Selectors][] for documentation on selectors for use anywhere they are accepted throughout the framework.
98 Native: Element {#Element}
99 ==========================
101 Custom Native to allow all of its methods to be used with any extended DOM Element.
105 Element Method: constructor {#Element:constructor}
106 --------------------------------------------------
108 Creates a new Element of the type passed in.
112 var myEl = new Element(element[, properties]);
116 1. element - (*mixed*) The tag name for the Element to be created or an actual DOM element.
117 2. properties - (*object*, optional) Calls the Single Argument version of [Element:set][] with the properties object passed in.
121 * (*element*) A new MooTools extended HTML Element.
125 var myAnchor = new Element('a', {
126 'href': 'http://mootools.net',
131 'border': '1px solid black'
137 'mouseover': function(){
138 alert('mouseovered');
145 - [$][], [Element:set][]
149 Element Method: getElement {#Element:getElement}
150 ------------------------------------------------
152 Gets the first descendant element whose tag name matches the tag provided. If [Selectors][] is included, CSS selectors may also be passed.
156 var myElement = myElement.getElement(tag);
160 1. tag - (*string*) Tag name of the element to find.
164 * (*mixed*) If a match is found, the Element will be returned. Otherwise, returns null.
168 var firstDiv = $(document.body).getElement('div');
172 - This method is also available for Document instances.
173 - This method gets replaced when [Selectors][] is included.
174 - [Selectors][] enhances [Element:getElement][] so that it matches based on CSS selectors.
178 - See [Selectors][] for documentation on selectors for use anywhere they are accepted throughout the framework.
182 Element Method: getElements {#Element:getElements}
183 --------------------------------------------------
185 Collects all decedent elements whose tag name matches the tag provided. If [Selectors][] is included, CSS selectors may also be passed.
189 var myElements = myElement.getElements(tag);
193 1. tag - (*string*) String of the tag to match.
197 * (*array*) An [Elements][] array of all matched Elements.
201 var allAnchors = $(document.body).getElements('a');
205 - This method is also available for Document instances.
206 - This method gets replaced when [Selectors][] is included.
207 - [Selectors][] enhances [Element:getElements][] so that it matches based on CSS selectors.
211 - See [Selectors][] for documentation on selectors for use anywhere they are accepted throughout the framework.
215 Element Method: getElementById {#Element:getElementById}
216 --------------------------------------------------------
218 Gets the element with the specified id found inside the current Element.
222 var myElement = anElement.getElementById(id);
226 1. id - (*string*) The ID of the Element to find.
230 * (*mixed*) If a match is found, returns that Element. Otherwise, returns null.
234 var myChild = $('myParent').getElementById('myChild');
238 - This method is not provided for Document instances as document.getElementById is provided natively.
242 Element Method: set {#Element:set}
243 ----------------------------
245 This is a "dynamic arguments" method. Properties passed in can be any of the 'set' properties in the [Element.Properties][] Hash.
249 myElement.set(arguments);
253 - Two Arguments (property, value)
254 1. property - (*string*) The string key from the [Element.Properties][] Hash representing the property to set.
255 2. value - (*mixed*) The value to set for the specified property.
256 - One Argument (properties)
257 1. properties - (*object*) Object with its keys/value pairs representing the properties and values to set for the Element (as described below).
261 * (*element*) This Element.
265 #### With Property and Value:
267 $('myElement').set('text', 'text goes here');
268 $('myElement').set('class', 'active');
269 //The 'styles' property passes the object to Element:setStyles.
270 var body = $(document.body).set('styles', {
271 'font': '12px Arial',
277 var myElement = $('myElement').set({
278 //The 'styles' property passes the object to Element:setStyles.
280 'font': '12px Arial',
282 'border': '1px solid #f00'
284 //The 'events' property passes the object to Element:addEvents.
286 'click': function(){ alert('click'); },
287 'mouseover': function(){ this.addClass('over') }
289 //Any other property uses Element:setProperty.
295 - All the property arguments are passed to the corresponding method of the [Element.Properties][] Hash.
296 - If no matching property is found in [Element.Properties][], it falls back to [Element:setProperty][].
297 - Whenever using [Element:setProperty][] to set an attribute, pass in the lowercase, simplified form of the property. For example:
298 - use 'for', not 'htmlFor',
299 - use 'class', not 'className'
300 - use 'frameborder', not 'frameBorder'
306 - [Element][], [Element.Properties][], [Element:setProperty][], [Element:addEvents][], [Element:setStyles][]
310 Element Method: get {#Element:get}
311 ----------------------------------
313 This is a "dynamic arguments" method. Properties passed in can be any of the 'get' properties in the [Element.Properties][] Hash.
317 myElement.get(property);
321 1. property - (*string*) The string key from the [Element.Properties][] Hash representing the property to get.
325 * (*mixed*) The result of calling the corresponding 'get' function in the [Element.Properties][] Hash.
329 #### Using Custom Getters:
331 var tag = $('myDiv').get('tag'); //Returns "div".
333 #### Fallback to Element Attributes:
335 var id = $('myDiv').get('id'); //Returns "myDiv".
336 var value = $('myInput').get('value'); //Returns the myInput element's value.
340 - If the corresponding accessor doesn't exist in the [Element.Properties][] Hash, the result of [Element:getProperty][] on the property passed in is returned.
344 - [Element][], [Element.Properties][], [Element:getProperty][]
348 Element Method: erase {#Element:erase}
349 --------------------------------------
351 This is a "dynamic arguments" method. Properties passed in can be any of the 'erase' properties in the [Element.Properties][] Hash.
355 myElement.erase(property);
359 1. property - (*string*) The string key from the [Element.Properties][] Hash representing the property to erase.
363 * (*mixed*) The result of calling the corresponding 'erase' function in the [Element.Properties][] Hash.
367 $('myDiv').erase('id'); //Removes the id from myDiv.
368 $('myDiv').erase('class'); //myDiv element no longer has any class names set.
372 - If the corresponding eraser doesn't exist in the [Element.Properties][] Hash, [Element:removeProperty][] is called with the property passed in.
376 - [Element][], [Element.Properties][], [Element:removeProperty][]
380 Element Method: match {#Element:match}
381 --------------------------------------
383 Tests this Element to see if it matches the argument passed in.
387 myElement.match(match);
391 1. match - can be a string or element
392 - (*string*) The tag name to test against this element. If [Selectors][] is included, any single CSS selectors may also be passed.
393 - (*element*) An element to match; returns true if this is the actual element passed in.
397 * (*boolean*) If the element matched, returns true. Otherwise, returns false.
401 #### Using a Tag Name:
403 //Returns true if #myDiv is a div.
404 $('myDiv').match('div');
406 #### Using a CSS Selector:
408 //Returns true if #myDiv has the class foo and is named "bar"
409 $('myDiv').match('.foo[name=bar]');
411 #### Using an Element:
414 $('myDiv').match(el); //Returns true
415 $('otherElement').match(el); //Returns false
419 Element Method: inject {#Element:inject}
420 ----------------------------------------
422 Injects, or inserts, the Element at a particular place relative to the Element's children (specified by the second the argument).
426 myElement.inject(el[, where]);
430 1. el - (*mixed*) el can be the id of an element or an element.
431 2. where - (*string*, optional: defaults to 'bottom') The place to inject this Element. Can be 'top', 'bottom', 'after', or 'before'.
435 * (*element*) This Element.
441 var myFirstElement = new Element('div', {id: 'myFirstElement'});
442 var mySecondElement = new Element('div', {id: 'mySecondElement'});
443 var myThirdElement = new Element('div', {id: 'myThirdElement'});
447 <div id="myFirstElement"></div>
448 <div id="mySecondElement"></div>
449 <div id="myThirdElement"></div>
451 #### Inject to the bottom:
455 myFirstElement.inject(mySecondElement);
459 <div id="mySecondElement">
460 <div id="myFirstElement"></div>
463 #### Inject to the top:
467 myThirdElement.inject(mySecondElement, 'top');
471 <div id="mySecondElement">
472 <div id="myThirdElement"></div>
473 <div id="myFirstElement"></div>
480 myFirstElement.inject(mySecondElement, 'before');
484 <div id="myFirstElement"></div>
485 <div id="mySecondElement"></div>
491 myFirstElement.inject(mySecondElement, 'after');
495 <div id="mySecondElement"></div>
496 <div id="myFirstElement"></div>
500 [Element:adopt](#Element:adopt), [Element:grab](#Element:grab), [Element:wraps](#Element:wraps)
504 Element Method: grab {#Element:grab}
505 ------------------------------------
507 Works as [Element:inject](#Element:inject), but in reverse.
509 Appends the Element at a particular place relative to the Element's children (specified by the where parameter).
513 myElement.grab(el[, where]);
517 1. el - (*mixed*) el can be the id of an element or an Element.
518 2. where - (*string*, optional: default 'bottom') The place to append this Element. Can be 'top' or 'bottom'.
522 * (*element*) This Element.
528 var myFirstElement = new Element('div', {id: 'myFirstElement'});
529 var mySecondElement = new Element('div', {id: 'mySecondElement'});
531 myFirstElement.grab(mySecondElement);
535 <div id="myFirstElement">
536 <div id="mySecondElement"></div>
541 [Element:adopt](#Element:adopt), [Element:inject](#Element:inject), [Element:wraps](#Element:wraps)
545 Element Method: adopt {#Element:adopt}
546 --------------------------------------
548 Works like [Element:grab](#Element:grab), but allows multiple elements to be adopted.
550 Inserts the passed element(s) inside the Element (which will then become the parent element).
554 myParent.adopt(el[, others]);
558 1. el - (*mixed*) The id of an element, an Element, or an array of elements.
559 2. others - (*mixed*, optional) One or more additional Elements separated by a comma or as an array.
563 * (*element*) This Element.
569 var myFirstElement = new Element('div', {id: 'myFirstElement'});
570 var mySecondElement = new Element('a', {id: 'mySecondElement'});
571 var myThirdElement = new Element('ul', {id: 'myThirdElement'});
573 myParent.adopt(myFirstElement);
574 myParent2.adopt(myFirstElement, 'mySecondElement');
575 myParent3.adopt([myFirstElement, mySecondElement, myThirdElement]);
580 <div id="myFirstElement" />
583 <div id="myFirstElement" />
587 <div id="myFirstElement" />
594 [Element:grab](#Element:grab), [Element:inject](#Element:inject), [Element:wraps](#Element:wraps)
598 Element Method: wraps {#Element:wraps}
599 --------------------------------------
601 Works like [Element:grab](#Element:grab), but instead of moving the grabbed element from its place, this method moves this Element around its target.
603 The Element is moved to the position of the passed element and becomes the parent.
607 myParent.wraps(el[, where]);
611 1. el - (*mixed*) The id of an element or an Element.
612 2. where - (*string*, optional: default 'bottom') The place to insert the passed in element. Can be 'top' or 'bottom'.
616 * (*element*) This Element.
622 <div id="myFirstElement"></div>
626 var mySecondElement = new Element('div', {id: 'mySecondElement'});
627 mySecondElement.wraps($('myFirstElement'));
631 <div id="mySecondElement">
632 <div id="myFirstElement"></div>
637 Element Method: appendText {#Element:appendText}
638 ------------------------------------------------
640 Works like [Element:grab](#Element:grab), but instead of accepting an id or an element, it only accepts text.
641 A text node will be created inside this Element, in either the top or bottom position.
645 myElement.appendText(text);
649 1. text - (*string*) The text to append.
650 1. where - (*string*, optional: default 'bottom') The position to inject the text to.
654 * (*element*) The current Element instance.
660 <div id="myElement">Hey.</div>
664 $('myElement').appendText(' Howdy.');
668 <div id="myElement">Hey. Howdy.</div>
672 Element Method: dispose {#Element:dispose}
673 ------------------------------------------
675 Removes the Element from the DOM.
680 var removedElement = myElement.dispose();
684 * (*element*) This Element. Useful to always grab the return from this function, as the element could be [injected](#Element:inject) back.
690 <div id="myElement"></div>
691 <div id="mySecondElement"></div>
695 $('myElement').dispose();
699 <div id="mySecondElement"></div>
703 - [MDC Element:removeChild](http://developer.mozilla.org/en/docs/DOM:element.removeChild)
707 Element Method: clone {#Element:clone}
708 --------------------------------------
710 Clones the Element and returns the cloned one.
715 var copy = myElement.clone([contents, keepid]);
719 1. contents - (*boolean*, optional: defaults to true) When set to false the Element's contents are not cloned.
720 2. keepid - (*boolean*, optional: defaults to false) When true the cloned Element keeps the id attribute, if present. Same goes for any of the cloned childNodes.
725 * (*element*) The cloned Element.
731 <div id="myElement"></div>
735 //Clones the Element and appends the clone after the Element.
736 var clone = $('myElement').clone().injectAfter('myElement');
740 <div id="myElement">ciao</div>
745 - The returned Element does not have attached events. To clone the events use [Element:cloneEvents](/Element/Element.Event#Element:cloneEvents).
746 - Values stored in Element.Storage are not cloned.
747 - The clone element and its children are stripped of ids, unless otherwise specified by the keepid parameter.
751 - [Element:cloneEvents](/Element/Element.Event#Element:cloneEvents).
755 Element Method: replaces {#Element:replaces}
756 --------------------------------------------------
758 Replaces the Element with an Element passed.
762 var element = myElement.replaces(el);
766 1. el - (*mixed*) A string id representing the Element to be replaced with, or an Element reference.
770 * (*element*) This Element.
774 $('myNewElement').replaces($('myOldElement'));
775 //$('myOldElement') is gone, and $('myNewElement') is in its place.
779 - [MDC Element:replaceChild](http://developer.mozilla.org/en/docs/DOM:element.replaceChild)
783 Element Method: hasClass {#Element:hasClass}
784 --------------------------------------------
786 Tests the Element to see if it has the passed in className.
790 var result = myElement.hasClass(className);
794 1. className - (*string*) The class name to test.
798 * (*boolean*) Returns true if the Element has the class, otherwise false.
804 <div id="myElement" class="testClass"></div>
808 $('myElement').hasClass('testClass'); //returns true
812 Element Method: addClass {#Element:addClass}
813 --------------------------------------------
815 Adds the passed in class to the Element, if the Element doesnt already have it.
819 myElement.addClass(className);
823 1. className - (*string*) The class name to add.
827 * (*element*) This Element.
833 <div id="myElement" class="testClass"></div>
837 $('myElement').addClass('newClass');
841 <div id="myElement" class="testClass newClass"></div>
845 Element Method: removeClass {#Element:removeClass}
846 ----------------------------
848 Works like [Element:addClass](#Element:addClass), but removes the class from the Element.
853 myElement.removeClass(className);
857 1. className - (*string*) The class name to remove.
861 * (*element*) This Element.
867 <div id="myElement" class="testClass newClass"></div>
871 $('myElement').removeClass('newClass');
875 <div id="myElement" class="testClass"></div>
879 Element Method: toggleClass {#Element:toggleClass}
880 --------------------------------------------------
882 Adds or removes the passed in class name to the Element, depending on whether or not it's already present.
886 myElement.toggleClass(className);
890 1. className - (*string*) The class to add or remove.
894 * (*element*) This Element.
900 <div id="myElement" class="myClass"></div>
904 $('myElement').toggleClass('myClass');
908 <div id="myElement" class=""></div>
912 $('myElement').toggleClass('myClass');
916 <div id="myElement" class="myClass"></div>
920 Element Method: getPrevious {#Element:getPrevious}
921 --------------------------------------------------
923 Returns the previousSibling of the Element (excluding text nodes).
927 var previousSibling = myElement.getPrevious([match]);
931 1. match - (*string*, optional): A tag name to match the the found element(s) with. If [Selectors][] is included, a full CSS selector can be passed.
935 * (*mixed*) The previous sibling Element or null if none found.
939 Element Method: getAllPrevious {#Element:getAllPrevious}
940 --------------------------------------------------------
942 Like [Element:getPrevious][], but returns a collection of all the matched previousSiblings.
946 Element Method: getNext {#Element:getNext}
947 ------------------------------------------
949 As [Element:getPrevious][], but tries to find the nextSibling (excluding text nodes).
954 var nextSibling = myElement.getNext([match]);
958 1. match - (*string*, optional): A comma seperated list of tag names to match the found element(s) with. If [Selectors][] is included, a full CSS selector can be passed.
962 * (*mixed*) The next sibling Element or null if none found.
965 Element Method: getAllNext {#Element:getAllNext}
966 ------------------------------------------------
968 Like Element.getNext, but returns a collection of all the matched nextSiblings.
972 Element Method: getFirst {#Element:getFirst}
973 --------------------------------------------
975 Works as [Element:getPrevious][], but tries to find the firstChild (excluding text nodes).
980 var firstElement = myElement.getFirst([match]);
984 1. match - (*string*, optional): A tag name to match the found element(s) with. if [Selectors][] is included, a full CSS selector can be passed.
988 * (*mixed*) The first sibling Element or null if none found.
992 Element Method: getLast {#Element:getLast}
993 ------------------------------------------
995 Works as [Element:getPrevious][], but tries to find the lastChild.
999 var lastElement = myElement.getLast([match]);
1003 1. match - (*string*, optional): A tag name to match the found element(s) with. if [Selectors][] is included, a full CSS selector can be passed.
1007 * (*mixed*) The first sibling Element, or returns null if none found.
1011 Element Method: getParent {#Element:getParent}
1012 ----------------------------------------------
1014 Works as [Element:getPrevious][], but tries to find the parentNode.
1019 var parent = myElement.getParent([match]);
1023 1. match - (*string*, optional): A tag name to match the found element(s) with. if [Selectors][] is included, a full CSS selector can be passed.
1027 * (*mixed*) The target Element's parent or null if no matching parent is found.
1031 Element Method: getParents {#Element:getParents}
1032 ------------------------------------------------
1034 Like [Element:getParent](#Element:getParent), but returns a collection of all the matched parentNodes up the tree.
1038 Element Method: getChildren {#Element:getChildren}
1039 --------------------------------------------------
1041 Returns all the Element's children (excluding text nodes). Returns as [Elements][].
1046 var children = myElement.getChildren([match]);
1050 1. match - (*string*, optional): A tag name to match the found element(s) with. if [Selectors][] is included, a full CSS selector can be passed.
1054 * (*array*) A [Elements](#Elements) array with all of the Element's children, except the text nodes.
1058 Element Method: hasChild {#Element:hasChild}
1059 --------------------------------------------
1061 Checks all descendants of this Element for a match.
1066 var result = myElement.hasChild(el);
1070 1. el - (*mixed*) Can be an Element reference or string id.
1074 * (*boolean*) Returns true if the passed in Element is a child of the Element, otherwise false.
1080 <div id="Darth_Vader">
1081 <div id="Luke"></div>
1086 if ($('Darth_Vader').hasChild('Luke')) alert('Luke, I am your father.'); // tan tan tannn...
1090 Element Method: empty {#Element:empty}
1091 --------------------------------------
1093 Empties an Element of all its children.
1102 * (*element*) This Element.
1108 <div id="myElement">
1115 $('myElement').empty();
1117 ##### Resulting HTML
1119 <div id="myElement"></div>
1123 Element Method: destroy {#Element:destroy}
1124 ------------------------------------------
1126 Empties an Element of all its children, removes and garbages the Element.
1127 Useful to clear memory before the pageUnload.
1131 myElement.destroy();
1139 Element Method: toQueryString {#Element:toQueryString}
1140 ------------------------------------------------------
1142 Reads the child inputs of the Element and generates a query string based on their values.
1147 var query = myElement.toQueryString();
1151 * (*string*) A string representation of a all the input Elements' names and values.
1157 <form id="myForm" action="submit.php">
1158 <input name="email" value="bob@bob.com" />
1159 <input name="zipCode" value="90210" />
1164 $('myForm').toQueryString(); //Returns "email=bob@bob.com&zipCode=90210".
1167 Element Method: getSelected {#Element:getSelected}
1168 --------------------------------------------------
1170 Returns the selected options of a select element.
1175 var selected = mySelect.getSelected();
1179 * (*array*) An array of the selected elements.
1185 <select id="country-select" name="country">
1186 <option value="US">United States</option
1187 <option value ="IT">Italy</option>
1192 $('country-select').getSelected(); //Returns whatever the user selected.
1196 This method returns an array, regardless of the multiple attribute of the select element.
1197 If the select is single, it will return an array with only one item.
1201 Element Method: getProperty {#Element:getProperty}
1202 --------------------------------------------------
1204 Returns a single element attribute.
1208 var myProp = myElement.getProperty(property);
1212 * property - (*string*) The property to be retrieved.
1216 * (*string*) A string containing the Element's requested property.
1222 <img id="myImage" src="mootools.png" title="MooTools, the compact JavaScript framework" alt="" />
1226 var imgProps = $('myImage').getProperty('src'); //Returns: 'mootools.png'.
1230 Element Method: getProperties {#Element:getProperties}
1231 ------------------------------------------------------
1233 Gets multiple element attributes.
1237 var myProps = myElement.getProperties(properties);
1241 * properties - (*strings*) Any number of properties to be retrieved.
1245 * (*object*) An object containing all of the Element's requested properties.
1251 <img id="myImage" src="mootools.png" title="MooTools, the compact JavaScript framework" alt="" />
1255 var imgProps = $('myImage').getProperties('id', 'src', 'title', 'alt');
1256 //Returns: { id: 'myImage', src: 'mootools.png', title: 'MooTools, the compact JavaScript framework', alt: '' }
1260 Element Method: setProperty {#Element:setProperty}
1261 --------------------------------------------------
1263 Sets an attribute or special property for this Element.
1268 1. property - (*string*) The property to assign the value passed in.
1269 2. value - (*mixed*) The value to assign to the property passed in.
1273 * (*element*) - This Element.
1279 <img id="myImage" />
1283 $('myImage').setProperty('src', 'mootools.png');
1285 ##### Resulting HTML
1287 <img id="myImage" src="mootools.png" />
1291 - Whenever using [Element:setProperty][] to set an attribute, pass in the lowercase, simplified form of the property. For example:
1292 - use 'for', not 'htmlFor',
1293 - use 'class', not 'className'
1294 - use 'frameborder', not 'frameBorder'
1298 Element Method: setProperties {#Element:setProperties}
1299 ------------------------------------------------------
1301 Sets numerous attributes for the Element.
1306 1. properties - (*object*) An object with key/value pairs.
1310 * (*element*) This Element.
1316 <img id="myImage" />
1320 $('myImage').setProperties({
1321 src: 'whatever.gif',
1322 alt: 'whatever dude'
1325 ##### Resulting HTML
1327 <img id="myImage" src="whatever.gif" alt="whatever dude" />
1331 Element Method: removeProperty {#Element:removeProperty}
1332 --------------------------------------------------------
1334 Removes an attribute from the Element.
1339 myElement.removeProperty(property);
1343 1. property - (*string*) The attribute to remove.
1347 * (*element*) This Element.
1353 <a id="myAnchor" href="#" onmousedown="alert('click');"></a>
1357 //Eww... inline JavaScript is bad! Let's get rid of it.
1358 $('myAnchor').removeProperty('onmousedown');
1360 ##### Resulting HTML
1362 <a id="myAnchor" href="#"></a>
1366 Element Method: removeProperties {#Element:removeProperties}
1367 ------------------------------------------------------------
1369 Removes numerous attributes from the Element.
1374 myElement.removeProperties(properties);
1378 1. properties - (*strings*) The attributes to remove, separated by comma.
1382 * (*element*) This Element.
1388 <a id="myAnchor" href="#" title="hello world"></a>
1392 $('myAnchor').removeProperties('id', 'href', 'title');
1394 ##### Resulting HTML
1399 Element Method: store {#Element:store}
1400 --------------------------------------
1402 Stores an item in the Elements Storage, linked to this Element.
1407 myElement.store(key, value);
1411 1. key - (*string*) The key you want to assign to the stored value.
1412 2. value - (*mixed*) Any value you want to store.
1416 * (*element*) This Element.
1420 $('element').store('someProperty', someValue);
1423 Element Method: retrieve {#Element:retrieve}
1424 --------------------------------------------
1426 Retrieves a value from the Elements storage.
1431 myElement.retrieve(key[, default]);
1435 1. key - (*string*) The key you want to retrieve from the storage.
1436 2. default - (*mixed*, optional) Default value to store and return if no value is stored.
1440 * (*mixed*) The value linked to the key.
1444 $('element').retrieve('someProperty'); // returns someValue (see example above)
1447 Element Method: eliminate {#Element:eliminate}
1448 --------------------------------------------
1450 Eliminates a key from the Elements storage.
1455 myElement.retrieve(key);
1459 1. key - (*string*) The key you want to eliminate from the storage.
1463 * (*mixed*) The element/window/document.
1467 $('element').eliminate('someProperty');
1473 Hash: Element.Properties {#Element-Properties}
1474 ==============================================
1476 This Hash contains the functions that respond to the first argument passed in [Element:get][], [Element:set][] and [Element:erase][].
1478 ### Adding a Custom Element Property
1480 Element.Properties.disabled = {
1483 return this.disabled;
1486 set: function(value){
1487 this.disabled = !!value;
1488 this.setAttribute('disabled', !!value);
1493 ### Using a Custom Element Property
1495 //Gets the "disabled" property.
1496 $(element).get('disabled');
1497 //Sets the "disabled" property to true, along with the attribute.
1498 $(element).set('disabled', true);
1502 Automatically returns the element for setters.
1504 ### Using an Object:
1506 Additionally, you can access these custom getters and setters using an object as the parameter for the [set](#Element:set) method.
1511 $(divElement).set({html: '<p>Hello <em>People</em>!</p>', style: 'background:red'});
1513 //For new Elements (works the same as set):
1514 new Element('input', {type: 'checkbox', checked: true, disabled: true});
1518 Element Property: html {#Element-Properties:html}
1519 -------------------------------------------------
1523 Sets the innerHTML of the Element.
1527 myElement.set('html', [htmlString[, htmlString2[, htmlString3[, ..]]]);
1531 1. Any number of string parameters with HTML.
1535 * (*element*) This Element.
1541 <div id="myElement"></div>
1545 $('myElement').set('html', '<div></div>', '<p></p>');
1547 ##### Resulting HTML
1549 <div id="myElement">
1556 Returns the inner HTML of the Element.
1560 myElement.get('html');
1564 * (*text*) This Element's innerHTML.
1568 Element Property: text {#Element-Properties:text}
1569 -------------------------------------------------
1573 Sets the inner text of the Element.
1577 myElement.set('text', text);
1581 1. text - (*string*) The new text content for the Element.
1585 * (*element*) This Element.
1591 <div id="myElement"></div>
1595 $('myElement').set('text', 'some text');
1596 //The text of myElement is now 'some text'.
1598 ##### Resulting HTML
1600 <div id="myElement">some text</div>
1604 Gets the inner text of the Element.
1608 var myText = myElement.get('text');
1612 * (*string*) The text of the Element.
1618 <div id="myElement">my text</div>
1622 var myText = $('myElement').get('text'); //myText = 'my text'.
1626 Element Property: tag {#Element-Properties:tag}
1627 -----------------------------------------------
1631 Returns the tag name of the Element in lower case.
1635 var myTag = myElement.get('tag');
1639 * (*string*) The tag name in lower case.
1645 <img id="myImage" />
1649 var myTag = $('myImage').get('tag'); // myTag = 'img'.
1653 Native: IFrame {#IFrame}
1654 ========================
1656 Custom Native to create and easily work with IFrames.
1660 IFrame Method: constructor {#IFrame:constructor}
1661 ------------------------------------------------
1663 Creates an IFrame HTML Element and extends its window and document with MooTools.
1668 var myIFrame = new IFrame([el][, props]);
1672 1. el - (*mixed*, optional) The id of the IFrame to be converted, or the actual IFrame element. If its not passed, a new IFrame will be created (default).
1673 2. props - (*object*, optional) The properties to be applied to the new IFrame. Same as [Element:constructor](#Element:constructor) props argument.
1677 * (*element*) A new IFrame HTML Element.
1681 var myIFrame = new IFrame({
1683 src: 'http://mootools.net/',
1688 border: '1px solid #ccc'
1693 mouseenter: function(){
1694 alert('Welcome aboard.');
1697 mouseleave: function(){
1702 alert('The iframe has finished loading.');
1712 - If the IFrame is from the same domain as the "host" or running locally, its document and window will be extended with MooTools functionalities, allowing you to fully use MooTools within it.
1713 - If the IFrame already exists and has a different name than id, the name will be made the same as the id.
1714 - If the IFrame is from a different domain, its window and document will not be extended with MooTools methods.
1718 Native: Elements {#Elements}
1719 ============================
1721 The Elements class allows [Element][] methods to work on an [Elements][] array, as well as [Array][] Methods.
1725 Elements Method: constructor {#Elements:constructor}
1726 ----------------------------------------------------
1731 var myElements = new Elements(elements[, options]);
1735 1. elements - (*mixed*) An array of elements or an HTMLCollection Object.
1739 * (*array*) An extended array with the [Element][], [Elements][] and [Array][] methods.
1743 #### Set Every Paragraph's Color to Red:
1745 $$('p').each(function(el){
1746 el.setStyle('color', 'red');
1749 //Because $$('myselector') also accepts Element methods, the below
1750 //example has the same effect as the one above.
1751 $$('p').setStyle('color', 'red');
1754 #### Create Elements From an Array:
1756 var myElements = new Elements(['myElementID', $('myElement'), 'myElementID2', document.getElementById('myElementID3')]);
1761 - In MooTools, every DOM function which returns a collection of nodes (such as [$$][]) returns the nodes as instances of Elements.
1762 - Because Elements is an Array, it accepts all the [Array][] methods, while giving precedence to [Element][] and [Elements][] methods.
1763 - Every node of the Elements instance has all the [Element][] methods.
1767 - [$$][], [$][], [Element][], [Elements][], [Array][]
1771 Elements Method: filter {#Elements:filter}
1772 ----------------------------------------------
1774 Filters a collection of elements by a given tag name. If [Selectors][] is included, this method will be able to filter by any selector.
1775 It also works like [Array:filter](/Native/Array/#Array:filter), by filtering collection of elements with a function.
1780 var filteredElements = elements.filter(selector);
1784 1. selector - (*mixed*) A single CSS selector.
1788 * (*array*) A subset of this [Elements][] instance.
1795 [Array]: /core/Native/Array
1796 [Selectors]: /core/Utilities/Selectors
1799 [Elements]: #Elements
1800 [Element:set]: #Element:set
1801 [Element:get]: #Element:get
1802 [Element:erase]: #Element:erase
1803 [Element:setProperty]: #Element:setProperty
1804 [Element:getProperty]: #Element:getProperty
1805 [Element:removeProperty]: #Element:removeProperty
1806 [Element:getElement]: #Element:getElement
1807 [Element:getElements]: #Element:getElements
1808 [Element.Properties]: #Element-Properties
1809 [Element:getPrevious]: #Element:getPrevious
1811 [Element:addEvents]: /core/Element/Element.Event#Element:addEvents
1812 [Element:setStyles]: /core/Element/Element.Style#Element:setStyles