Getting started with jQuery Lesson 1 jQuery selector _ jquery

Source: Internet
Author: User
To operate an element on the page, you must first select it, which requires a selector. The selector can be considered as an enhanced getElementById method. The getElementById method returns an HTML element, and the jQuery selector returns a pack of HTML elements. With this package set, jQuery gives HTML elements more operational methods. In JQuery, $ is a core function. Yes, it is a function and its name is a bit odd. This function is used to select a function. Its general usage is

Var obj = $ (selector );

The selector is a string, which is the selector that will be introduced below. The returned result is a collection of elements. In fact, the power of JQuery's core $ function is far more than used as a selector. When its parameter is a function, its function is similar to the onload event, when the DOM element of the page is fully loaded, the methods in its parameters will be executed. It is more advantageous than onload. onload can only register one function, but it can be called multiple times, that is, it can register multiple functions and load them completely to the DOM for execution, in addition, onload is executed after all the content on the page is loaded. If there are large images and other content, it may cause function execution delay. The $ function can be executed as long as the DOM structure is fully loaded. The following is a simple example:

The Code is as follows:




JQuery First Page

Related Article

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.