Dom objects into jquery objects

Source: Internet
Author: User

Compared to jquery into the DOM, more of the development is the processing of a DOM object into a jquery object. $ (parameter) is a versatile method that produces different effects by passing different parameters.

If the argument passed to the $ (DOM) function is a DOM object, the jquery method wraps the DOM object into a new jquery object.

After the normal DOM object is processed into a jquery object through the $ (DOM) method, we can invoke the jquery method.

HTML code

< Div > Element One </div><Div> element two </ Div > < Div > Elements three </div>

JavaScript code

var div=document.getelementsbytagname (' div '); // DOM Object var $div =$ (DIV); // jquery Object var $first = $div. Frist (); // find the first DIV element $first. css (' Color ', ' red '); // set the color of the first element

The getelementsbytagname gets the element to the DIV node, and the result is a DOM-collection object, but this object is a set of number combinations (3 div elements). The $ (div) method is used to convert the jquery object by invoking the first and CSS methods in the JQuery object to find and change its color.

Dom objects into jquery objects

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.