Preface:
From kaibo to the present, I have been trying to write something, But after reading a few days of books, I found that new things are hard to go deep, but I don't want to make a blog so I decided to summarize what I learned before, in text. On the one hand, it is easy to check for missing items in your learning; on the other hand, it is necessary to exercise your expressive ability and check whether you have a thorough understanding, can you share your knowledge and experience with others to integrate into a team for better learning and communication.
Preparations:
1. get jquery: In the big aspect, jquery has two versions: The full version and the compressed version (min ), there is no difference in the use of these two versions, except that the min version is compressed, smaller in size, and better in use on the network, but there is no function castrated. (Tip: I used to be stupid, and thought that Min is compressed. People say that the full version should be used for learning, but now I know that, in the past, the Experts learned the jquery source code! Therefore, if you want to use jquery, using Min is enough. If you really want to learn the jquery source code, you should check the full version)Jquery: http://code.jquery.com/jquery-1.7.1.min.js
2. make an Editor: notepad ++ or Vim (do not use notepad or ide as much as possible. At the beginning of Taiyuan, it is too difficult to eat too much memory. To learn, we always need to constantly repair, modify, and modify it)
Vim is still very comfortable to use after Syntax of JS is changed.
Notepad is easy to use and does not require complex configurations. It is recommended to use it.
Get started:
First, you need to import the jquery Library to the HTML file that requires it. First, let's give an example.
1 < Html >
2 < Head >
3 < Title > </ Title >
4 < Style >
5
6 </ Style >
7 < Script SRC = "Jquery. js" > </ Script >
8 < Script Type = "Text/JavaScript" >
9 $ (Document). Ready ( Function (){
10 $ ( ' P ' ). Click ( Function (){
11 $ ( ' P ' ). Text ( ' Hello jquery! ' );
12 });
13 });
14 </ Script >
15 </ Head >
16 < Body >
17 < P > Hello world! </ P >
18 </ Body >
19 </ Html >
This is an example of a complete jquery Dom operation. First import the jquery File<ScriptSRC= "Jquery. js"> </Script>, And the following is jquery'sCode.
$ (Document). Ready (Function(){............});
This is the beginning of almost every jquery script. It is intended to execute operations after all DOM elements are loaded.
Read this sentence:
1$ ('P'). Click (Function(){
2$ ('P'). Text ('Hello jquery! ');
3});
First, select the P element for the selector, and then bind a click event to change the content of the P element to hello jquery.
Each Command is divided into four parts: jquery function (or its alias), selector (similar to CSS in usage), action, and parameter. For example:
| Selector |
Action |
Parameters |
| Jquery ('P ') |
. CSS |
('Color', 'Blue ') |
| $ ('P ') |
. CSS |
('Color', 'Blue ') |
The two statements are exactly the same. $ is an alias of jquery. Jquery creates a jquery object. All its function methods are under this object. Its alias $ can also be handed over at any time, so it does not conflict with the top-level variables of JavaScript and can coexist with other JavaScript libraries.