jquery Basic Selector (get method of instance and form field value) _jquery

Source: Internet
Author: User
Tags prev

The jquery base selector includes a CSS selector, a hierarchy selector, and a form field selector.

1.CSS Selector

(1) Tag Selector

$ ("div") $ ("P") $ ("table") a series of HTML tags

(2) ID Selector

<input id= "User" type= "text" >

Gets the value of the tag: $ ("#user"). Val ();

(3) class selector

<input type= "text" class= "T" >

Add a style to the text box: $ (". T"). CSS ("Border", "2px solid Blue");

(4) Universal Selector

$ ("*"). CSS ("Color", "red"); Set styles for all elements

(5) Group Selector

$ ("div,span,p. StyleClass"). CSS ("Border", "1px solid Red"); Set border properties for all Div, span, and p elements that apply the StyleClass class

2. Hierarchy Selector

(1) Child element Selector

$ ("Parent > Child");

Finds all child elements below the parent element, excluding grandchild elements, and so on.

(2) Descendant element selector

$ ("ancestor Descedant");

Finds all child elements, grandchild elements, scion elements, and so on for the ancestor element.

(3) Immediate sibling element selector

$ ("Prev+next");

Sibling, and immediately following the element next element behind the Prev element

(4) adjacent sibling element selector

$ ("prev~siblings");

All siblings elements that follow the Prev and peers

3. form Field Selector

(1): Input Selector

$ (": input");

Select all input, textarea, select, button elements.

(2): Text selector

$ (": text");

Select all Single-line text boxes (<input type= "text"/>).

(3):p Assword Selector

$ (":p assword");

Select all Password boxes (<input type= "password"/>).

(4): Radio Selector

$ (": Radio");

Select all radio buttons (<input type= "Radio"/>).

(5): CheckBox Selector

$ (": checkbox");

Select all check boxes (<input type= "checkbox"/>).

(6): File selector

$ (": File");

Select all file Domains (<input type= "file"/>).

(7): Iamge Selector

$ (": Iamge");

Select all image fields (<input type= "Iamge"/>).

(8): Hidden selector

$ (": hidden");

Select all hidden Fields (<input type= "hidden"/>) and all invisible elements (the CSS display property value is None).

(9): Button Selector

$ (": Button");

Select All buttons (<input type= "button"/>) and <button>...</button>

(a): Submit Selector

$ (": Submit");

Select all Submit buttons (<input type= "submit"/>) and <button>...</button>

(one): Reset Selector

$ (": Reset");

Select all the reset buttons (<input type= "reset"/>) and <button>...</button>

For form field selectors, these are all elements that get all of a type. Gets the value of one of the elements, which is reflected in the following instance. The running effect diagram and code for the instance are as follows:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >  

After clicking the "Submit" button, the following dialog box pops up:

The above jquery basic selector (example and form field value acquisition method) is a small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.

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.