Section 2 of Singleton jquery in 2014: Singleton jquery in 2014

Source: Internet
Author: User

Section 2 of Singleton jquery in 2014: Singleton jquery in 2014

* ************ Jquery syntax ******************

1. jquery selects HTML elements and performs some operations on the selected elements to complete some special effects.

2. Therefore, we often see the following operations when using jQuery: $ (selector). function ()

3. here, the $ symbol is a shortcut operator, and the selector in the parentheses after it specifies the HTML element we want to make an error, and then we execute this action to complete the operation on the element.

4. For example, $ ("p"). hide () is also a method we used in the previous section. We can use it to hide the content in the p tag.

5. jQuery selector is a combination of xPath and CSS selector syntax.


*********************

1. if you carefully read the sample code in the previous section, you will find that all our code is written in a function. Below we will describe it in the form of pseudo code:

$ (Document). ready (// other Code );

2. it means to execute the corresponding code after all the documents are loaded. If the documents are not fully loaded, some operations may fail, for example, when we try to operate an element that does not exist, the Operation will fail.


************************

1. we also learned from the above that it is very important for jQuery to find the correct HTML element through the selector, because only in this way will subsequent operations be effective, our results will be displayed.

2. jQuery allows us to operate HTML elements or a single element.

3. The jQuery selector allows us to find this HTML element through the element id, class, type, attribute, attribute value, etc. Its syntax is similar to our CSS selector.

4. jQuery must start with $ () when searching for selectors.

5. here are a few examples. For example, $ ("p") selects all p tags. For example, $ ("# xin") selects an HTML element with the id as xin, for example, $ (". xin ") is an HTML element that selects all class attributes as xin.


*********************

1. To make the interaction between our web pages and users more friendly, jQuery provides powerful event processing capabilities.

2. The event handler is the method called when something happens in HTML. It is easy to understand if you have GUI programming knowledge.

3. for example, common DOM events include click, dbclick, mouseenter, and mouseleave ), keyboard Events include keypress, keydown, and keyup.

4. it is necessary to mention the Form Events, such as submit, chane, foucus, and blur, there are also load, resize, scroll, and unload of documents and windows ).

5. For example, if we need to trigger an event when clicking a p tag, we can use $ ("p"). click ();

6. What should we write in the click function? We can implement it by defining a Javascript function.

7. We usually have an equivalent jQuery Method for most DOM events.


**************

1. $ (document). ready (): It is an operation performed after the document is fully loaded.

2. The click () method is a mouse click event.

3. The mouseenter () method is an event where the mouse pointer passes through the element.

4. The mouseleave () method is an event where the mouse pointer leaves the element.

5. The mousedown () method is an event where the mouse pointer moves over the element and the left mouse button is pressed.

6. The mouseup () method is the time when the mouse pointer moves over the element and the mouse is released.

7. The hover () method is used to hover the cursor over an element. It accepts two functions, one for mouse entry and the other for mouse exit.

8. The focus () method is used to obtain focus events. Most of the events are selected by clicking the mouse or locating an element through the tab key.

9. The blur () method is used for events when HTML elements lose focus.


*****************

1. We can write the code to another js file, and then import the js file and jQuery file we wrote.

2. Import the jQuery file first. The import format is as follows:


***************

1. This section ends now and shows us how to use the jQuery library.

2. The usage is to call $ (selector) after the document is loaded. The format of the function is manipulated.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.