jquery Entry-level Part.1

Source: Internet
Author: User
Tags tag name

The jquery selector:

Basic selector:

#id gets an element based on the attribute value of the ID

TagName to get elements based on tag name

Selector1,selector2 the selector in the matching list

. class gets an element based on the attribute value of class

Hierarchy Selector:

Ancestor element descendant element matches the ancestor element below the specified descendant element

Parent > Child matches the specified sub-element under the parents element

Prev + Next matches the next sibling element of the current element requires that these two elements must be neighbors

Prev~siblings matches all sibling elements specified below the current element

Simple selector:

: First matches one element

: Last matches final element

: Even matches all elements with an even number of subscripts

: Odd matches all elements with an odd subscript value

: EQ (index) matches the element with the specified value

: GT (index) matches all elements with a subscript value greater than the specified value

: LT (index) matches all elements of the subscript value less than the specified value

: Not (selector) matches all elements that do not contain the specified selector

Content selector:

: Contains (text) matches the element containing the specified value in the content

: Empty matches element with null content

: The element with the specified selector in the has (selector) match content

:p arent elements that match content is not empty

Visibility Selector:

: Hidden matches hidden elements in CSS: Display:none

: Visible matches the displayed element In CSS: Display:block

Property Selector:

[attribute] matches all elements of the specified property

[Attribute=value] matches an element that is equal to a specified value Input[name= "username"]

[Attribute!=value] Match property not equal to all elements of the specified value

[Attribute^=value] Match property to specify all elements that begin with a value

[Attribute$=value] matches all elements of the property to the end of the specified value

[Attribute*=value] matches all elements of the property that contain the specified value

[Selector1] [Selector2] [Selectorn] matches all attributes in the list

child element selector:

: Nth-child (index/even/odd) matches the index value to the specified value or the index value is a sub-element of parity here is the 1 start

: The first child element of First-child

: Last-child Last child element

: Only-child matches and has only one child element

!CSS3 can also be used

Form Property Selector:

: Input matches all elements in the form containing select TEXTAREA! $ ("input") it is matched to all the input tags! $ (": input") it is matched to all form control elements except the input tag of select textarea

: Text matches a single line textbox

:p assword match single line Password box

: Radio Match radio button

: CheckBox matching Multi-select button

: Submit Match Submit button

: Reset Match reset button

: Image Match Picture button

: Button matches normal button

: File Matching files upload

: Hidden matches hidden fields if you want to match the hidden field controls in the form, you must first add the input label $ ("Input:hidden")

Form Object selector:

: Enabled to match form controls that are available in the form

:d isabled form controls that are not available in a matching form

: Checked matches the default selected element radio button and the multi-select button in the form

: Selected matches the default selected element drop-down list in the form

the jQuery object and the JavaScript object are converted to each other:

The jquery object is converted to a JavaScript object:

Method: jquery Object [subscript ]

To convert a JavaScript object to a jquery object:

Method:$ (JavaScript object )

The methods in jQuery manipulate the attributes in the HTML tag:

attr (name) Gets the value of the specified property of the current object

attr (Key,value) Sets the property value for the current object

attr (properties) setting multiple property values for the current object at a time requires that the parameter be a JSON object

REMOVEATTR (name) moves the property name and property values of the current object

the class attribute in the jQuery Object action Label:

AddClass (Class) Adds a class property value to the current object

Removeclass (Class) Removes the Class property value of the current object

Toggleclass (Class) If there is a specified class attribute value in the current object is removed and the inverse is added

Hasclass (Class) returns True if there is a specified class property value, otherwise it returns false

The jQuery Object operates on the style property in the label:

CSS (name) Gets the property value of the CSS style specified by the Style property of the current object

CSS (key,value) to set CSS styles in the Style property of the current object

CSS (properties) set multiple requirement parameters at once must be a JSON object

Size Method:

Width () width (value) height () height (value)

text, Value:

HTML (): Get content from a bilateral tag

HTML (val): setting content toward a bilateral marker

Val (): Gets the value in the single-sided tag

Val (val): Set the value in the single-sided Tag Value property

Text (): Gets the contents of a bilateral tag

Text (val): Set content toward the bilateral marker

The difference between the HTML () and the text () methods: one can parse HTML tags one cannot parse

HTML () gets all the contents of the tag in the

Text () gets only the textual content in the tag

jquery Entry-level Part.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.