1, selectors.
$ ("id"): ID selector, select only the ID name element, when selected, do not write the id name prefix "#";
$$ ("*"): Mixed selector, applicable to all elements, usage is very similar to jquery.
2, Dom is ready.
/* The following is excerpted from the network (translation) */
We often use window.onload or body onload= "" to perform loading events on some pages.
Such as
Window. onload=myfunction;
There are some drawbacks to this approach: first, we have to wait for the picture in the page to be loaded before executing the script (JS). Also, if there are some events and code bound to the window on our page, they will overwrite each other.
MooTools has developed a solution for this situation. When the DOM in the page is ready, MooTools comes with a custom event called Domready.
Such as
Window. addevent(' Domready ', function(){
MyFunction();
});
When the DOM in the HTML page is loaded, theMyFunction executes immediately, and the other window and image are immediately followed.
What are the advantages of Domready:
* Allow your work page to load first.
* Allows you to use the same event with other scripts.
* Do not wait for the picture to finish loading.
Domready Demonstration
/*
MooTools Domready.
The other Styles.
1. Call the function directly.
2. The function is inside of anonomos function.
*/
Window.addevent ( ' Domready ' , myfunction< Span class= "Br0") //or.
window. addevent ( ' Domready ' , function ({
myfunction< Span class= "Br0" ( })
function myfunction ( {
alert ( "the DOM is ready.") /span>
"The above content belongs to their own translation, if the error please help to provide comments, thank you"
mootools--Study notes (1)