JQuery filter selector details

Source: Internet
Author: User

JQuery filter selector details
Select the first element (: first) as the basic filter selector)

// Select the first div element. $ ('# btn1'). click (function () {$ ('div: first'background .css (background, # bfa );})
Select the last element (: last)
// Select the last div element. $ ('# btn2'). click (function () {$ ('div: last'background .css (background, # bfa );})
Removes all elements that match the given selector (: not (selector ))
// Select all div elements whose class is not one. $ ('# btn3 '). click (function () {$ ('div: not(.one+'background .css (background, # bfa );})
Select all the elements whose index is an even number. The index starts from 0 (: even)
// Select the div element with an even index value. $ ('# Btn4'). click (function () {$ ('div: even'mirror.css (background, # bfa );})
Select all the elements whose indexes are odd, and the index starts from 0 (: odd)
// Select the div element with an odd index value. $ ('# Btn5'). click (function () {$ ('div: odd'hangzhou.css (background, # bfa );})
Select the element whose index is equal to the specified index. The index starts from 0 (: eq (index ))
// Select the element whose index is equal to 3 $ ('# btn6'). click (function () {$ ('div: eq(3366'+.css (background, # bfa );})
Select an element whose index is greater than the specified index. The index starts from 0 (: gt (index ))
// Select an element with an index greater than 3 $ ('# btn7'). click (function () {$ ('div: gt(3366'}.css (background, # bfa );})
Select the element whose index is smaller than the specified index. The index starts from 0 (: lt (index ))
// Select the element whose index is less than 3 $ ('# btn8'). click (function () {$ ('div: lt(3366'+.css (background, # bfa );})
Select the title element (: header)
// Select all title elements. such as h1, h2, h3, etc... $ ('# btn9 '). click (function () {$ (': header'background .css (background, # bfa );})
Select all the elements (: animated) of the animation being executed)
// Select all elements of the animation currently being executed. $ ('# btn10'). click (function () {$ (': animated'background .css (background, # bfa );});
Select all elements (: focus) that are currently getting the focus)
// Select all elements of the current retrieved focus. $ ('# btn11'). click (function () {$ (': focus'background .css (background, # bfa );});
The content filtering selector selects the elements that contain the specified text (: contains (text ))
// Select the div element containing the text di. $ ('# btn1'). click (function () {$ ('div: contains(dimo-'background .css (background, # bbffaa );})
Select an empty element (empty) that does not contain child elements or text)
// Select a div empty element that does not contain child elements (or text elements. $ ('# btn2 '). click (function () {$ ('div: empty'background .css (background, # bbffaa );})
Select the element containing the selector Matching Element (: has (selector ))
// Select the div element. $ ('# btn3'). click (function () {$ (div: has('.mini'{}.css (background, # bbffaa);}) that contains the mini element );})
Select an empty element (parent) that contains child elements or text)
// Select the div element containing the child element (or text element. $ ('# btn4 '). click (function () {$ ('div: parent'background .css (background, # bbffaa );})
The visibility filter selects invisible elements (: hidden)
// Select all invisible elements, including. $ ('# Btn_hidden'). click (function () {$ ('div: hidden'{.show(3000).css (background, # bbffaa );})
Select visible elements (: visible)
// Select all visible elements. $ ('# btn_visible'). click (function () {$ ('div: visible'background .css (background, # FF6500 );})
Attribute filter selects the element with this attribute ([attribute])
// Select the div element containing the property title. $ ('# btn1'). click (function () {region ('div?title='background .css (background, # bbffaa );})
Select an element whose property value is value ([attribute = value])
// Select the div element whose property title value is equal to test. $ ('# btn2'). click (function () {comment ('div?title=test}'}.css (background, # bbffaa );})
Select an element whose property value is not equal to value ([attribute! = Value])
// Select the div element. $ ('# btn3'). click (function () {$ ('div [title! Using testbench 'hangzhou.css (background, # bbffaa );})
Select the element whose attribute value starts with value ([attribute ^ = value])
// Select the div element whose attribute title value starts with te. $ ('# btn4'). click (function () {comment ('div=title={te}'background .css (background, # bbffaa );})
Select the element whose attribute value ends with value ([attribute $ = value])
// Select the div element whose attribute title value ends with est. $ ('# btn5'). click (function () {vertex (div1_title1_1_est1_1_1_.css (background, # bbffaa );})
Select the element whose property value contains value ([attribute * = value])
// Select the div element whose attribute title value contains es. $ ('# btn6 '). click (function () {$ (div [title * =es]).css (background, # bbffaa );})
Select an element ([attribute | = value]) whose property value is equal to value or whose prefix is value (that is, "value-xxx").
// Select the element $ ('# btn3') whose attribute title is equal to en or whose prefix is en (followed by a hyphen '). click (function () {$ ('div [title | incluen}'background .css (background, # bbffaa );})
Select the elements ([attribute ~ = Value])
// Select the element of the uk character in the space-separated attribute title value. $ ('# btn4'). click (function () {$ ('div [title ~ =Ukw.'hangzhou.css (background, # bbffaa );})
Combination attribute selector ([attribute1] [attribute2]… [AttributeN])
// Combine the property selector. First, select the div element with the property id, and then select the element with the property title value containing es in the result. $ ('# btn7 '). click (function () {$ (div [id] [title * =es]).css (background, # bbffaa );})
The child element filtering selector selects the first child element under each parent element and returns the collection element.
// Select the first child element $ ('# btn2') under each parent element '). click (function () {$ ('div. one: first-child').css (background, # bbffaa );})
Select the last child element under each parent element and return the collection element.
// Select the last child element under each parent element $ ('# btn3 '). click (function () {$ ('div. one: last-child').css (background, # bbffaa );})
Select the unique child element under each parent element and return the set element.
// If only one child element exists under the parent element, select this child element $ ('# btn4 '). click (function () {$ ('div. one: only-child').css (background, # bbffaa );})
Select the index sub-element or parity element under each parent element. The index starts from 1.
// Select the 2nd child elements under each parent element $ ('# btn1 '). click (function () {$ ('div. one: nth-child(2w.'hangzhou.css (background, # bbffaa );})

 

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.