MooTools 1.2 JavaScript library introduction
MooTools 1.2 is a powerful lightweight JavaScript library, specially designed to ease interactive JavaScript development in the Web. In a way, you can think of MooTools as an extension of CSS. For example, CSS allows you to change things when you mouse over them. JavaScript allows you to touch more events (click events, mouseover events, keyboard events...), and MooTools makes it very easy.
In addition, MooTools also has a variety of very good extensions that allow you not only to change the properties of an element, but also allow you to have "morph" (deformation) or "tween" (tween animation) properties. , giving you the ability to create animated effects like the ones you see on my navigation menu (Fdream note: from the original author, also on my homepage).
This is just an example, MooTools allows you to do more. Over the next 30 days, we'll dive into the MooTools library, exploring everything from Arrays and Functions to Fx.Slide, and other bundled plugins.
Reference MooTools 1.2
First, download and reference the MooTools 1.2 core library.
Download the MooTools 1.2 core library
Upload the MooTools 1.2 core library to your server or workspace
Link the MooTools 1.2 core library within the head tag of your HTML document
Reference code:
(Fdream Note: After MooTools 1.2 is downloaded, the default suffix is ".txt" , please change the suffix to ".js".)
Add Script tag inside the Head tag
Now that you have applied MooTools to your page, you still need a place to write your code . There are two options here:
1. Write the following code within your head tag, and your code within the script tag:
Reference code:
2. Create a JavaScript file externally, and then link this file at the head of the page:
Reference code:
Here, you can use any method. I usually put the methods called in the domready event between script tags, and my functions in external files.
Put the code in domready
MooTools methods must be called in the domready event.
Reference code:
window.addEvent('domready ', function() {
exampleFunction();
});
(Fdream note: This is not exactly the case, but it can ensure that your JavaScript code has as few errors as possible. By the way, the domready event: When the HTML code of the page (not including pictures, flash, etc., just the code) is downloaded, the domready event will be triggered. This way, the page can be completely downloaded (including pictures, flash, etc.) ) before executing your script to avoid exceptions caused by the script not being able to execute because a large picture will take a long time to download)
Put the code in a function
You can still create it outside of domready. your function and then call it in domready:
Reference code:
var exampleFunction = function() {
alert('hello')
};
window.addEvent('domready', function() {
exampleFunction();
});
A detailed introduction to the library
In this first lecture, we will take a closer look at some of the key components of this library's architecture, and then take a cursory look at other basic features.
Core
The core part contains some public functions of the MooTools library to complete some common tasks, and also enhances many original functions (details will be introduced later). The following content is only used as some examples of MooTools functions and does not replace your reading of MooTools documentation.
Checks for a value (returns false if there is no value or is 0) - $chk(value);
Returns a random integer between two values - $random(min, max);
Okay Easier to detect browsers, browser engines and browser capabilities
(Fdream note: the first description is wrong, $chk(value) just checks whether a value has been defined or assigned, when it is 0 Will return true, only return false if undefined or null)
Native (local object)
This part of the library also contains some public tools that allow you to easily manipulate arrays (Arrays, values or objects). simple list), function, number, string, hash object and event. Here are some utility features in native objects:
Execute a script for each element in the array - .each();
Get the last element in the array - .getLast();
Each Trigger an event for )
A JavaScript class (as opposed to a CSS class) is an object whose functionality can be reused. To learn more about MooTools classes, you can check out this simple introductory article by Valerio (MooTools Classes – How to Use Them). I also recommend David Walsh’s MooTools templates.
Element (Element)
The Element class of the MooTools library provides some very useful functions. Through this class, you can select DOM elements, manipulate their properties and positions, and change their CSS styles. Here are some very powerful tools for processing DOM elements provided by MooTools:
Select the first DOM element of a specified type by ID or CSS class name - .getElements();
Select all with the same ID or CSS class DOM element named - .getElements();
Add a CSS class to an element - .addClass();
Get the attribute value of an element - .getProperty();
Change the attribute value of an element - .setProperty();
Get the style attribute value of an element - .getStyle();
Change the style attribute value of an element - .setStyle();
Get the coordinate position of an element - .getCoordinates ();
(Fdream note: It is not recommended to have multiple identical IDs in one page. It is best not to appear. Unforeseen errors may easily occur in some browsers.)
Utilities
Utilities provide more sophisticated selection logic, including domready events, tools that can manage AJAX calls, tools that can easily manage cookies, and even a "swiff" function that can provide a JavaScript interface to ActionScript.
FX (Effects)
This is probably the most interesting part of MooTools. Through Fx (effect), you can create "Tween" (tween animation) and "morph" (morph animation) effects to animate your DOM objects.
Create an animated transformation between two style attribute values (such as making a div grow gently) - var myFx = new Fx.Tween(element);
Create between multiple different attribute values An animation transformation (for example, in the process of making a div gradually grow larger, its border becomes smaller and smaller, and its background color changes at the same time) - var myFx = new Fx.Morph(element);
Request (request )
Contains tools to easily handle JavaScript XMLHttpRequest (AJAX) functionality. To ease the pain of the entire request/response, the Request object also has some extensions designed to handle HTML and JSON objects (JavaScript Object Notation).
Plugins
MooTools plug-ins extend the core functionality and can easily add advanced UI features to your web projects. The list of plugins is as follows:
Fx.Slide
Fx.Scroll
Fx.Elements
Drag
Drag.Move
Color
Group
Hash.Cookie
Sortables
Tips
SmoothScroll
Slider
Scroller
Assets
Accordion
Global Overview
Before starting the next lecture, take a moment to take a comprehensive look at the MooTools documentation. There may be some parts that you don't understand, so don't worry about it. Just read it through and absorb what you understand. Over the next 29 days, we'll gradually dive into specific parts of the library and break down MooTools into digestible bite-sized pieces, but first, be sure to take a good look at the entire catalog.
Learn more
A zipped package that contains everything you need to get started
Includes a MooTools 1.2 core library, a simple HTML file, and a script to write your The function of an external JavaScript file, a CSS style sheet file. This HTML file has been written with detailed comments and contains the domready event.
MooTools 1.2 Memo
Here is a good summary list of MooTools 1.2 functions. I just printed a copy for myself and am looking for a place to hang it up. Maybe I should stop by the printer and ask them to provide me with a poster-sized one :). Anyway, here is the link to the MooTools 1.2 cheat sheet.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor