Basic knowledge of JQuery

Source: Internet
Author: User
Tags jquery library

First, the introduction of the jquery Library way

1 1 <!--introduced jquery-->2 2 <script type= "Text/javascript" src= "Scripts/jquery-1.3.1.js" > </script>3 3 <script type = "Text/javascript" >4 4     $ (document). Ready (function  () {5 5        alert ("HelloWorld"6 6     }); 7 7 </script>

Second,jquery object/dom Object

1.jQuery objects are objects that are produced after wrapping a DOM object through JQuery ($ ())

2.jQuery objects are unique to jQuery. If an object is a jquery object, then it can use the method in jquery: $ ("#persontab"). html ();

3.jQuery objects cannot use any method of the DOM object, nor can the DOM object use any of the methods in JQuery

4. Convention: If you get a JQuery object, precede the variable with $.
-var $variable = JQuery Object
-var variable = DOM Object

Third,JQuery objects into DOM objects

jquery objects cannot use methods in the DOM, but if jquery does not encapsulate the desired method, it has to use the DOM object, as in the next two ways:

The 1.jQuery object is an array object, and the corresponding DOM object can be obtained by means of the [index] method.

-var $CR = $ ("#cr");

-var cr = $CR [0];

2. Use the Get (index) method in JQuery to get the corresponding DOM object

-var $CR = $ ("#cr");

-var cr = $cr. Get (0);

Iv.DOM objects into JQuery objects

For a DOM object, you can get a jquery object by wrapping the DOM object with $ () (the jquery object is the object that was created after wrapping the DOM object with jquery).

-var CR = document.getElementById ("Cr");

-var $CR = $ (CR);

Basic knowledge of JQuery

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.