What are the basic selectors for jquery and jquery, the hierarchy selector, the basic filter

Source: Internet
Author: User
Tags tag name

What is jquery? 

[1] jquery was created by American John Resig and has attracted many JavaScript gurus from around the world to join its team.

[2] jquery is another excellent JavaScript framework following prototype. Its purpose is--write Less,do more!

[3] It is a lightweight JS library (only 21k after compression), this is not the other JS library, it is compatible with CSS3, but also compatible with a variety of browsers

[4] jquery is a fast, concise JavaScript library that makes it easier for users to handle htmldocuments, events, animate, and easily provide Ajax interactivity to websites.

[5] The big advantage of jquery is that its documentation is full, and that the various applications are detailed, as well as a number of mature plugins to choose from.

The advantages of jquery

A lightweight JS frame. The jquery core JS file is only dozens of KB and does not affect page loading speed.

A rich Dom selector, jquery's selection is handy, such as to find a DOM object adjacent elements, JS may have to write several lines of code, and jquery line of code is done, such as to a table of interlaced color, jquery is a line of code.

Chained expressions. jquery's chained operations can be more concise by writing multiple operations in one line of code.

event, style, animation support. jquery also simplifies the javascript operation of the CSS code, and the code is more readable than JS.

Ajax operation Support. jquery simplifies Ajax operations, and the backend simply returns a JSON-formatted string to complete communication with the front-end.

Cross-browser compatible. jquery is basically compatible with today's mainstream browsers, without having to worry about browser compatibility issues.

Plug-in extension development. jquery has a rich third-party plug-in, such as: Tree menu, date control, picture switch plug-ins, pop-ups and so on the basic front-end page of the components have corresponding plug-ins, and with the jquery plug-in made out of the effect is very dazzling, and can adapt to their own needs to rewrite and encapsulate plug-ins, simple

What is a jQuery object?

The jquery object is the object that is generated after wrapping the DOM object through jquery. jquery objects are unique to jquery . if an object is a jquery object , then it can use the method in jquery : $ ( "#test"). html ()

$ ("#test"). html ()             means: Gets the HTML code within the element with ID test. where HTML () is the method in jquery          This code is equivalent to using the DOM implementation code: document.getElementById ("Test"). InnerHTML;          Although jquery objects are created after wrapping a DOM object, jquery cannot use any of the methods of the DOM object, nor does the DOM object use the method in JQuery. The error         convention is that if you get a jquery object, you need to precede the variable with $. var $variable = jQuery Object var variable = Dom Object $variable[0]:jquery object converted to DOM object      $ ("#msg"). html (); $ ("#msg") [0].innerhtml

Basic syntax for jquery:$ (selector). Action ()

Reference: http://jquery.cuishifeng.cn/

Find Element (selector and filter) selector base Selector
All elements $ ("*")//Find $ ("#id")//Based on ID////Find $ ("   . Class") based on the class name/  /find $ ("element")//combination selector by tag name $ ("  . Class,p, Div ")
Hierarchy Selector
Descendant selector $ (". Outer div")  //descendant selector $ (". Outer>div")   //Adjacent selector $ (". Outer+div")//  brother selector (rear brother tag) $ (". outer~ Div ")
Basic filters
The first $ ("Li:first")  //Index is 2 ("Li:eq (2)")//index value is even $ ("  Li:even")//index value is odd $ ("li:odd")//index value is greater than 1 of $ ("LI:GT (1)" )//index value less than $1 ("LI:LT (1)")//Remove all elements matching the given selector, id not D1 Li label $ ("Li:not (#d1)")//Match element containing the element that the selector matches: has (element name)  

What are the basic selectors for jquery and jquery, the hierarchy selector, the basic filter

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.