The difference between 2018-08-26 jquery and JavaScript and the core method

Source: Internet
Author: User

Tag: The His div Java function adds color traversal test

1.JQ objects are normal objects generated by the JS new object.

2.JQ objects and JS objects, their methods cannot be shared!

3.jq object and JS Object Mutual Transformation:

JS object to JQ object, $ (js_obj);//This way, js_obj can use the JQ method;

    $ (js_obj). Click (function () {});

JQ object to JS object->①$ (' div ') [0];//So, the JQ object can use the JS method;

②$ (' div ') get (0);//In this way, the JQ object can use the JS method;

    $ (' div ') [0].INNERTHML = "abc";

4.JQ function body the difference between $ (this) and this;

$ (this), on behalf of the JQ object;

This-> represents this Dom object;

   $ (' div '). Click (function () {
this.innerhtml = "ABC";
$ (this). HTML (' abc ');

These two methods achieve consistent results, combined with the above 3rd is not difficult to see the principle

})

5.JQ Core Approach

The traversal of each () object (can pass parameter i);

    $("img").each(function(i){

      this.src = "test" + i + ".jpg";

    });

Size () contains the number of JQ objects in the body;

Length property, function ibid.

Get (), obtain the first several JQ objects and convert them to JS objects ;

A.index (b) The index of the->a object in the B object;

Add attributes (JSON format) to the JQ object, data ();

   Jq_obj.data ({' Age ', 20})

  

The difference between 2018-08-26 jquery and JavaScript and the core method

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.