Use of jQuery-Selectors (selector) (ix. Table object attributes)

Source: Internet
Author: User

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!
After testing in IE6, IE7, and Firefox, the results can be achieved.
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 run the code div id = "div_a1"
Span ID = "span_a1"

texteara
Select 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 this code div id = "div_b1"
Span ID = "span_b1"

texteara
Select 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 details about how to use has (selector), see content & visibility section 3rd. For details about [type = 'checkbox'] 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 the fourth button to execute this code.

The Code is as follows:<Script type = "text/javascript">
$ ("# Btn_4"). click (function (){
Var SelectedText = $ ("# div_d1: selected ");
For (var I = 0; I <SelectedText. length; I ++)
{
$ ("# Div_d1_1"). append (I + 1) + "." + SelectedText [I]. text + '<br/> ');
}
});
</Script>

 

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.

  Article introduction:

Use of jQuery-Selectors (selector) (1. Basic)

Use of jQuery-Selectors (selector) (level 2)

Use of jQuery-Selectors (selector) (III. Simple)

Use of jQuery-Selectors (selector) (IV-V. Content & visibility)

Use of jQuery-Selectors (selector) (6. Attribute)

Use of jQuery-Selectors (selector) (vii. subelement)

Use of jQuery-Selectors (selector) (8. Form)

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.