First knowledge of jquery

Source: Internet
Author: User

about jquery

jquery is a fast, concise JavaScript framework that is a good JavaScript code base ( or JavaScript framework ) after prototype. The purpose of jquery design is "write Less,do more", which advocates writing less code and doing more things. It encapsulates the functionality code common to JavaScript, providing a simple JavaScript design pattern that optimizes HTML document manipulation, event handling, animation design, and Ajax interaction.

The core features of jquery can be summed up with a unique chain syntax and a short and clear multi-function interface, a highly efficient and flexible CSS selector, and the ability to extend the CSS selector, with convenient plug-in extension mechanisms and rich plugins. jquery is compatible with a variety of mainstream browsers such as IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+, and more.

Why study jquery?

  JavaScript的功能很强大,同时也存在很多缺点,比如存在浏览器兼容处理,代码容错性差,入口函数只能有一个,假如多个话此时覆盖...

1    function () {    //Entry function 12           //  JS code 3   }4  5    function () {   //Entry function 26           //  JS code 7    }

At this point, the code below (entry function 2) overwrites the code above (entry function 1), but jquery solves these problems well.

jquery Official website: http://jquery.com jquery version: 1.x--support IE6~IE8 2.x and 3.x--no longer supported IE6~IE8 when we're using jquery, it's best to choose 1.7+ version, 1.7 The previous version is too old and is not recommended for use.

jquery Preliminary

1. Using the jquery Trilogy: The Primer and the entry function = Business logic
1 // Introducing jquery Packages 2 <script src= "Js/jquery-1.11.1.min.js" ></script>3 <script>4    //   Entry function 5    $ (function() {6        ///   Business Logic 7    }); 8 </script>

Two common ways to import functions:

A) $ (document). Ready (function () {});
b) $ (function () {});

The entry function for jquery ($ (function () {}) is executed as long as the DOM tree is loaded, does not need to wait for the loading of pictures, files, etc., and the entry function of JavaScript (window.onload = function () {} ) is to begin execution after all pictures, files, and so on in the document have been loaded.

2, $ symbol

$--is a function, the parameters are different, the function is different, but jquery and $ are completely equivalent (jquery = = $), as long as there is a place can have jquery to replace.

1 <script>2     $ ("#id")-  -   selector 3     $ ("<div> create Dom</div>")-  -   Create Dom4 5     jQuery (". Class")  --   selector 6 </script>

3. Conversion between jquery objects and Dom objects

  Dom object:

js method gets the page element returned by the object is the DOM object, DOM object can only use the DOM object's methods or properties      obj.innerHTML = "....";

  jQuery对象:

     使用jQuery方法获取页面中的元素返回的对象就是jQuery对象, such as $ ("div"), $ ("#btn"), jquery objects can only use the method $ ("#btn") of the JQuery object. Show ();

The following syntax error

     $("div").innerHTML = "jquery快乐学习";      document.getElementById("box").show();

jquery Object Goto DOM Object

$ ("div") [index]----DOM object (recommended); Index is a number starting at 0 ("div"). Get (Index)----DOM object; Index is a number starting from 0

Dom object to jquery Object

$ (DOM object)---jquery object

First 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.