"Learning Notes" sharp jquery (a) selector

Source: Internet
Author: User

First, the main points elaborated

1,jquery was created in January 2006 as an open source project, emphasizing the concept of "write Less,domore", compressed size around 30KB. 、

The methods in 2,jquery are set by the design process to automatically manipulate objects, rather than individual objects.

The 3,jq object is an array-like object that is produced after the JQ wrapper over the DOM object, and can be turned into a DOM object using the [0] or get (0) method.

Ii. conflict Resolution of jquery and other JS libraries

// the JQ library needs to be called noconflict () before other libraries are imported Mode 1 (jQuery instead of $): Jquery.noconflict ()  ; // Give control of the $ to other libraries.  jQuery (function () {...}); Mode 2 ($XHH instead of $):var $xhh = jquery.noconflict (); $xhh (function () {...}); Mode 3 (still in $): Jquery.noconflict (); JQuery (function ($) {...}); Mode 4 (still in $): jquery.noconflict ();(function ($) {    $ (function () {...});}) {jQuery}; // The JQ Library is imported after other libraries, with jquery instead ofjquery (function () {...});

Third, jquery selector

1, basic selector and Hierarchy selector

//Basic Selector$("#id")$(". ClassName")$("P")$("*")//Select All$("#id,. Classname,p")//Select multiple//Hierarchy Selector$("Div span")//all span descendants of a DIV$("Div>span")//Sub-element span of Div$("Div+span")//equivalent to $ ("div"). Next ("span")$("Div~span")//equivalent to $ ("div"). Nextall ("span"), note the distinction. Siblings ()

2, filter Selector

//Basic Filtration: First/:last//equivalent to: eq (0)/:eq (len-1): Not (selector)/: Has (selector): even/: Odd:eq (Index)/:GT (Index)/:LT (index)//Index starting from 0//child element Filtering: Nth-child (index/even/odd): first-child/:last-child:only-child//select its unique child element//Content Filtering: Contains ("XXX")//elements that contain text content with "XXX": empty/:p Arent//That includes child elements, excluding child elements.//Expression Filtering: Header//H1,h2,h3 ... Label: Animated:focus//the element that currently gets the focus: Hidden//including <input type= "hidden", "Display:none", "Visibility:hidden": Visible//attribute FilteringDiv[id] div[class=classname]div[class!=Classname]div[title^=value]//Div with property starting with valueDiv[title$=value]//attribute div with value endDiv[title*=value]//div with value in attributeDiv[attribute1][attribute2] ...//Multiple attribute Filters

3, form selector and corresponding filter

form selector : input  // elements of all forms, including Input,select,button ... // Select a table cell for the type attribute : Text:password:radio:checkbox:submit:image:reset:button:file:hidden   // A special choice is to include all the invisible elements outside the form  Form filtering : Enabled/:d isabled:checked: Selected

4,jq commonly used methods of selection

Filter (selector)  // filtering itself find (selector)   // filter in Descendants

"Learning Notes" sharp jquery (a) selector

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.