Use of jquery selectors (selector) (ix. Table object attributes)

Source: Internet
Author: User

This series Article It consists of nine articles: basic, level, simple, content, visibility, attribute, subelement, form, and form object attribute.
This topic explains: enabled,: Disabled,: checked,: Selected usage.
If you have any suggestions or comments on this series of articles, please send to: sjzlgt@qq.com
Because it is the first time to write a series of technical articles, it is inevitable that errors or Code Bug. Thank you!
After running, you need to refresh and load jquery <textarea id="runcode36449"></textarea> Xmlns = "http://www.w3.org/1999/xhtml">


Use of jquery-selectors (selector) (ix. Table object attributes)

This series of articles mainly describes how to use selectors in the jquery framework. I will describe them in the form of examples. It is based on simplicity and comprehensiveness and will not involve much depth. My learning method is as follows: get started first, and then go to advanced level!

This series of articles includes nine articles: basic articles, level articles, simple articles, content articles, visibility articles, attributes articles, child elements articles, forms articles, and form object attributes articles.

This topic explains: enabled,: Disabled,: checked,: Selected usage.

If you have any suggestions or comments on this series of articles, please send to: sjzlgt@qq.com

As this is the first time to write a series of technical articles, errors or code bugs are inevitable. Thank you!

You can go to the official jquery website to learn more about jquery.

Copyright: code-cat blog: http://www.cnblogs.com/bynet reprint please keep the original author, source and copyright information!After testing in IE6, IE7, and Firefox, the results can be achieved.1. enabled usage

Definition: match all available elements

Returned value: array <element>

Example: change the background color of all available input elements in the div id "div_a1" to red.

Code: $ ("# div_a1 input: enabled" ).css ("background-color", "Red ");// Click the button to execute the code

Div id = "div_a1"


SPAN id = "span_a1"


Texteara </P> <SELECT> <option> select </option> </SELECT> <p> <input type = "button" id = "btn_1" value = "button 1 "Class =" button ">2. Disabled usage

Definition: match all unavailable Elements

Returned value: array <element>

Example: change the background color of all unavailable input elements in Div with ID "div_b1" to red.

Code: $ ("# div_b1 input: Disabled" ).css ("background-color", "Red ");// Click button 2 to execute the code

Div id = "div_b1"


SPAN id = "span_b1"


Texteara </P> <SELECT> <option> select </option> </SELECT> <p> <input type = "button" id = "btn_2" value = "button 2 "Class =" button ">3. Checked usage

Definition: match all selected elements (check box, single-choice, etc., excluding option in select)

Returned value: array <element>

Example: change the background color of all elements in the DIV with ID "div_c1" that contain the check box in the selected status to red.

Code: $ ("# div_c1: Has (input [type = 'checkbox']: checked)" ground .css ("background-color", "Red ");// Click "3" to execute the code.

Div id = "div_c1"


SPAN id = "span_c1"

Div id = "div_c1_1"
Div id = "div_c1_2"
Div id = "div_c1_3"
Div id = "div_c1_4"

NOTE: For the usage of has (selector), see content & visibility Article 3rd,
[Type = 'checkbox'] for usage, see attribute section 2nd.
4.: Selected usage

Definition: match all selected option Elements

Returned value: array <element>

Example: write the text value of option in all select elements in Div with ID "div_d1" to div_d1_1.

Code: var selectedtext = $ ("# div_d1: Selected ");// Click button 4 to execute the code

Div id = "div_d1"


SPAN id = "span_d1"

SPAN option1SPAN option2SPAN option3

Div select1Div C #Div VBDiv jquery Div select2Div AppleDiv interDiv Google Div select3Div U. S..Div U. K.Div China Div id = "div_d1_1"

Note: append (content) points to an element to Append content. It will be explained in later sections. Stay tuned.

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.