Juqery learning 3 selector visibility element attribute _ jquery

Source: Internet
Author: User
Juqery learns the attributes of the selector visibility element. For more information, see. : Hidden matches all invisible elements. If the type attribute of the input element is "hidden", it will also be matched Matches all elements that are hidden, or input elements of type "hidden". Return Value

Array

Example

Search for all invisible tr Elements

HTML code:




Value 1
Value 2

JQuery code:

$ ("Tr: hidden ")

Result:

[Value 1]

Bytes ---------------------------------------------------------------------------------------

: Visible matches all visible elements Matches all elements that are visible. Return Value

Array

Example

Search for all visible tr Elements

HTML code:




Value 1
Value 2

JQuery code:

$ ("Tr: visible ")

Result:

[Value 2]

Bytes ---------------------------------------------------------------------------------------

[Attribute] matches the element containing the given attribute Matches elements that have the specified attribute. Return Value

Array

Parameters

Attribute(String): attribute name

Example

Search for all the p elements containing the id attribute

HTML code:


Hello!



JQuery code:

$ ("P [id]")

Result:

[

]

Bytes ---------------------------------------------------------------------------------------

[Attribute = value] matching a given attribute is an element of a specific value Matches elements that have the specified attribute with a certain value. returned value

Array

Parameters

Attribute(String): attribute name

Value(String): attribute value. Quotation marks are optional in most cases. However, it is used to avoid conflicts when an attribute value contains.

Example

Find all input elements whose name attribute is newsletter

HTML code:

'

JQuery code:

$ ("Input [name = 'newsletter ']"). attr ("checked", true );

Result:

[ , ]

Bytes ---------------------------------------------------------------------------------------

[Attribute! = Value] matching a given attribute is an element that does not contain a specific value Matches elements that don't have the specified attribute with a certain value. returned value

Array

Parameters

Attribute(String): attribute name

Value(String): attribute value. Quotation marks are optional in most cases. However, it is used to avoid conflicts when an attribute value contains.

Example

Find all input elements whose name attribute is not newsletter

HTML code:

'

JQuery code:

$ ("Input [name! = 'Newsletter '] "). attr (" checked ", true );

Result:

[ ]

Bytes ---------------------------------------------------------------------------------------

[Attribute ^ = value] matching a given attribute is an element starting with some values Matches elements that have the specified attribute and it starts with a certain value. Return value

Array

Parameters

Attribute(String): attribute name

Value(String): attribute value. Quotation marks are optional in most cases. However, it is used to avoid conflicts when an attribute value contains.

Example

Find all input elements whose names start with 'new'

HTML code:



JQuery code:

$ ("Input [name ^ = 'News']")

Result:

[ , ]

Bytes ---------------------------------------------------------------------------------------

[Attribute $ = value] matches the given attribute with elements ending with some values. Matches elements that have the specified attribute and it ends with a certain value. Return value

Array

Parameters

Attribute(String): attribute name

Value(String): attribute value. Quotation marks are optional in most cases. However, it is used to avoid conflicts when an attribute value contains.

Example

Find all input elements whose names end with 'letter'

HTML code:



JQuery code:

$ ("Input [name $ = 'Letter ']")

Result:

[ , ]

Bytes ---------------------------------------------------------------------------------------

[Attribute * = value] matching a given attribute is an element that contains certain values. Matches elements that have the specified attribute and it contains a certain value. Return value

Array

Parameters

Attribute(String): attribute name

Value(String): attribute value. Quotation marks are optional in most cases. However, it is used to avoid conflicts when an attribute value contains.

Example

Find all input elements whose names contain 'man'

HTML code:




JQuery code:

$ ("Input [name * = 'man']")

Result:

[ , , ]

Bytes ---------------------------------------------------------------------------------------

[Selector1] [selector2] [selectorN] composite attribute selector, which must meet multiple conditions at the same time. Matches elements that have the specified attribute and it contains a certain value. Return value

Array

Parameters

Selector1(Selector): attribute Selector

Selector2(Selector): another property Selector to further narrow down the scope.

SelectorN(Selector): any number of attribute selectors

Example

Find all the attributes that contain id and whose name attributes end with man.

HTML code:




JQuery code:

$ ("Input [id] [name $ = 'man']")

Result:

[ ]
Related Article

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.