jquery Learning 1

Source: Internet
Author: User

Learning jquery in the process found a blog to the main points of jquery is very good, excerpt its essence for learning. Thank you: http://blog.csdn.net/wph_1129/article/details/5993290

1,jquery Object Access

Each (callback) is similar to a foreach loop in C #.

$ ("Element"). Length the number of an object in an HTML page.

$ ("Element"). Size () The number of an object in an HTML page.

$ ("element"). Get () gets a collection of elements in an HTML page, constructed as an array.

$ ("element"). Get (index) gets the element of index subscript. The index starts at 0.

$ ("element"). Get (). Reverse () Reverses the elements within the array.

$ ("element"). Index ($ ("element") gets the indexed value of the element in index that matches the object.

2,jquery Selector

$ ("*") indicates that all objects are selected.

$ ("#element") indicates that an element with ID is selected. Id=

$ (". ABC") indicates that an element of the class style using ABC is selected. class=

$ ("div") represents the selection of all DIV elements in the HTML. Elementname=

$ ("#a,. B,p") means that the Get ID is a, or use class style B, or all P elements. Combine relationships (or).

$ ("#a. B P") indicates that the get ID is an element of a and contains all P elements that use style B. Hierarchical relationship. and

3,jquery crash-Hierarchical object acquisition

$ ("Element1 Element2 Element3 Element4 Element2 ...") represents the element that gets the level of the former parent of the latter child

$ ("div > Input") gets all input tag elements under Div

$ ("div + input") that matches a P tag element immediately following the DIV element

$ ("div ~ P") represents all P elements that match the DIV element

$ ("Element:first") represents the first of a type of label element in an HTML page.

$ ("Element:last") represents the last of a type of label element in an HTML page.

$ ("Element:not (selector)") removes all elements that match the given selector. Example: $ ("Input:not (: Checked)") indicates that all unchecked check boxes are selected.

$ ("Elemnt:even") means that even rows are obtained, counting from 0 onwards.

$ ("elemnt:odd") means to get odd lines, counting from 0 onwards.

$ ("Element:eq (Index)") matches an element of a given index value, starting at 0. Example: $ ("Div:eq (3)") Gets the 4th div of a page

$ ("ELEMENT:GT (Index)") the element index that matches all label elements that are greater than the given index value does not contain the given index value starting from 0

$ ("Element:it (Index)") matches all element values that are less than the given index value the index element does not contain a given index value, starting with 0

$ (": Header") represents an element that matches H1 H2 H3.

$ ("element:animated") to match all elements that are not in the animation effect

4,jquery crash-acquisition and object visibility of content objects

$ ("Element:contains (text)") indicates whether the text in the matching LABEL element contains a letter or a string.

$ ("Element:empty") means that the Get element does not contain text or child elements.

$ ("Element:parent") indicates that the Get object element contains text or child elements.

$ ("Element:has (selector)") indicates whether an element is contained in a match. Example $ ("P:has (span)") represents all P elements that contain a SPAN element

$ ("Element:hidden") indicates that all invisible elements are matched. Includes Display:none input Type=hidden

$ ("element:visible") indicates that all visible elements are matched.

5,jquery crash-Object acquisition advanced

$ ("Element[id]") indicates that all tag elements with an id attribute are obtained.

$ ("Element[attribute = ko]") means getting all elements of a property with a value of KO.

$ ("Element[attribute! = ko]") means getting all elements of a property value that are not KO.

$ ("Element[attribute ^= Ko]") represents an element that gets all of the property values that begin with KO.

$ ("Element[attribute $= Ko]") represents an element that gets all of a property value ending in Ko.

$ ("Element[attribute *= ko]") means getting all the elements of a property value containing KO.

$ ("element[selector1][selector2][...]") means that the attribute selector is met, and the example $ ("Input[id][name][value=ko]") indicates the ID, Name and value are the input elements of KO.

6,jquery Quick-acquisition of child elements

$ ("Element:nth-child (Index)")
Select the nth child element under the parent, the index starts at 1, and the EQ function (the EQ function learns later) starts at 0.
: Nth-child (even) even
: Nth-child (odd) odd
: Nth-child (3n) expression
: Nth-child (2) Index
: Nth-child (3n+1) expression
: Nth-child (3n+2) expression

$ ("Element:first-child") indicates that the first child element under the parent is matched.

$ ("Element:last-child") represents the last child element under the parent level.

$ ("Element:only-child") represents an example of a unique child element under a matching parent: DT is unique in the DL list, then DT is selected.

7,jquery crash-getting a Form object

$ (": Input") indicates that the match INPUT element type is input button select textarea

$ (": text") means matching all single-line text boxes

$ (":p assword") means matching all password boxes

$ (": Radio") means matching all radio buttons

$ (": CheckBox") indicates that all check boxes are matched

$ (": Submit") means match all submit buttons

$ (": reset") means matching all reset buttons

$ (": Button") means matching all buttons

$ (": File") means matching all file upload domains

$ (": hidden") means matching all invisible elements or elements of type value hidden

$ (": Enabled") means a match for all available input elements example: radio:enabled means matching all available radio buttons

$ (":d isabled") indicates that all input elements that are not available are matched.

$ (": Checked") indicates that all selected check box elements are matched.

$ (": Selected") matches all drop-down lists.

8,jquery Express-the setting and removal of element properties.

$ ("Element"). attr (name) represents a property value that gets the first matching element.

$ ("element"). attr (Key,value) indicates that the value of the property is set for an element.

$ ("element"). attr ({Key:value,key,value,....}) represents a value that sets multiple values at once for an element.

$ ("element"). attr (key,function) indicates that a computed property value is set for all matching elements.

$ ("Element"). Removeattr (name) means to remove a property.

9,jquery Express-Filter

$ ("element"). The EQ (index) means to get the nth element. Index is counted from 0. $ ("div"). EQ (3) Gets the 6th DIV element in an HTML page

$ ("element"). Hasclass ("ClassName") checks whether the current element has a particular class, if any, returns true.

$ ("element"). Filter ("Expression1, Expression2, Expression3,......") indicates that the collection of elements that match the specified expression is selected.

$ ("Element"). Filter ("function") using the same as

$ ("element"). Is ("expression") means that an expression is used to examine the collection of elements, as long as one of the matches returns true.

$ ("element"). Map ("callback") converts a set of elements into other arrays.

$ ("element"). Not ("expression") deletes the element that matches the specified expression.

$ ("Element"). Slice (start,end) begins to select the location of the subset. The first element is 0. If it is a negative number, you can start with the tail of the collection. End (Integer): (optional) ends the selection of its own position, or, if not specified, the end of itself.

10,jquery Express-Find

$ ("element"). Add ("Expressions") adds an element that matches an expression to a jquery object.

$ ("Element"). Children ("Expressions") means that the matched child elements are filtered by an optional expression. Parents will find all ancestral elements. Children () only considers all descendant elements.

$ ("element"). Contents () means getting the child element content of an element.

$ ("element"). Find ("Expressions") means searching for child elements below an element. Example $ ("div"). Find ("P") equals $ ("div p")

$ ("Element"). Next ("Expressions") means getting all the elements of the same layer behind an element.

$ ("element"). Nextall ("Expressions") represents all elements after the current element is found and can be filtered using an expression.

$ ("element"). Prev ("Expressions") represents a collection of elements that contain the same layer that each element in the matching element collection is immediately adjacent to.

$ ("element"). The parent ("Expressions") represents the collection of elements that contain the unique parent element for all matching elements.

$ ("element"). Parents ("Expressions") represents a collection of elements (without root elements) that contains the ancestor elements of all matching elements. You can filter by an optional expression.

$ ("element"). Siblings ("Expressions") finds all the same elements in front of the current element and can be filtered with an expression.

11,jquery Express-Internal insertion

$ ("element"). Append ("Content") represents an append to the element.

$ ("Element"). AppendTo ("content") means that the selected content is appended to the inside of another element. Equivalent to reversing $ ("Element"). Append ("Content")

$ ("element"). Prepend ("content") appends content to the selected element and is pre-placed.

$ ("element"). Prependto ("content") appends the selected element to the inside of another element and is pre-placed. Equivalent to reversing $ ("Element"). Prepend ("content")

12,jquery Express-External insert

$ ("element"). After ("Content") represents the addition of content to the selected element.

$ ("element"). Before ("content") means adding content to the front of the selected element.

$ ("element"). InsertAfter ("content") inserts the selected element into the content and reverses the $ ("element"). After ("content")

$ ("element"). InsertBefore ("content") inserts the selected element in front of the content and reverses the $ ("element"). Before ("content")

13,jquery Express-Parcel

$ ("element"). Wrap ("HTML") means that the matched elements are surrounded by a structured tag of other elements, respectively. Example: $ ("P"). Wrap ("") or $ ("P"). Wrap ("")

$ ("Element"). Wrap ("Elem") Ibid. Example: $ ("P"). Wrap ($ ("#Element"))

$ ("element"). Wrapall ("HTML") means that all matching elements are wrapped together with a single element example: $ ("P"). Wrapall ("") will wrap all p using a div

$ ("Element"). Wrapall ("Elem") ibid.

$ ("Element"). Wrapinner ("HTML") means that the child content of each matched element (including the text also belongs to the child element) is wrapped up in an HTML structure example: $ ("P"). Wrapinner ("")

$ ("Element"). Wrapinner ("Elem") ibid.

14,jquery crash-Replace, delete, and copy

Replace

$ ("Element"). ReplaceWith ("Contet") indicates that all matching elements are replaced with the specified HTML or DOM elements.

$ ("element"). ReplaceAll ("selector") indicates that all selector matching elements are replaced with matching elements.

Delete

$ ("element"). Empty () indicates that all child nodes in the matching element are deleted. (text also belongs to child nodes).

$ ("element"). Remove ("Expressions") means that the matching element is removed from the DOM.

Copy

$ ("Element"). Clone () indicates that the matching DOM elements are copied and the replicas of those clones are selected.

$ ("element"). Clone ("True") indicates that the element is processed with all its events and that copies of those clones are selected. For example, a button with an event, he will copy himself, the event can also be copied.

15,jquery Express-Assignment of elements

Html

$ ("Element"). HTML () represents the HTML code that gets the specified element

$ ("Element"). The HTML ("Val") represents the HTML code that sets the specified element. (The HTML code is the same as in normal body)

Text

$ ("Element"). Text () to get the text that appears in the specified LABEL element

$ ("element"). Text ("Val") to set the content of the specified label element

Value

$ ("Element"). Val () Gets the value of input check, select, radio, etc. can be obtained

$ ("Element"). The HTML ("Val") setting specifies the value of input.

16,jquery Express-style settings and definitions

$ ("element"). AddClass ("class") indicates that a defined class style is added for the obtained element.

$ ("element"). Removeclass ("class") indicates that the class style used is removed for the obtained element.

$ ("element"). Toggleclass ("class") means that when the acquired element uses a defined style to remove the style, it is not used and the style is added.

$ ("element"). The CSS ("name") represents the CSS style that gets an element. Example: $ ("div"). CSS ("color") represents the color of the get div.

$ ("element"). CSS (Name,value) represents the value assigned to the CSS style property of the acquired element.

$ ("Element"). CSS ({name: "value", Name: "Value", Name: "Value",......}) Represents the assignment of multiple CSS style attributes for an acquired element.

$ ("element"). Offset () represents the integer property of the returned element, which is top and left, respectively.

$ ("element"). Width () indicates the width of the obtained element.

$ ("element"). Width ("Val") indicates the width of the set get element.

$ ("element"). Height () indicates the height of the obtained element.

$ ("element"). Width ("Val") indicates the height of the set get element.

The above is the basic part of the summary, the following link is mainly about the event mechanism in jquery: http://blog.csdn.net/wph_1129/article/details/5993290

Thank the author again.

jquery Learning 1

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.