Basic filter selector explanation of jquery Selector

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Style type = "text/css">
/* Highlight */
. Highlight {
Background-color: gray
}
</Style>

Copy codeThe Code is as follows:
<Body>
<H3> provincial and municipal administrative divisions <Table border = "1" width = "50%">
<Thead>
<Tr>
<Th> Beijing </th>
<Th> Shanghai </th>
<Th> Shangqiu </th>
</Tr>
</Thead>
<Tbody>
<Tr>
<Td> Haidian </td>
<Td> Xuhui </td>
<Td> Fuyang </td>
</Tr>
<Tr>
<Td> Chaoyang </td>
<Td> Zhabei </td>
<Td> liangyuan </td>
</Tr>
<Tr>
<Td> Changping </td>
<Td> Whampoa </td>
<Td> Greentown </td>
</Tr>
</Tbody>
</Table>
</Body>

I.: first
Copy codeThe Code is as follows:
$ ("Tr: first"). addClass ("highlight"); // obtain the first matching tr element.



Ii.: last ()
Copy codeThe Code is as follows:
$ ("Tr: last"). addClass ("highlight"); // obtain the last matching tr element.



3. not (selector)
Copy codeThe Code is as follows:
$ ("Td: not (: even)"). addClass ("highlight"); // get the td except that the index is an even number.




Iv. even
Copy codeThe Code is as follows:
$ ("Tr: even"). addClass ("highlight"); // matches all elements whose index values are even and starts counting from 0.



V. odd
Copy codeThe Code is as follows:
$ ("Tr: odd"). addClass ("highlight"); // matches all elements with odd index values and starts counting from 0.



Vi. eq (index)
Copy codeThe Code is as follows:
$ ("Tr: eq (2)"). addClass ("highlight"); // matches the element of a given index value



VII.: gt (index)
Copy codeThe Code is as follows:
$ ("Tr: gt (1)"). addClass ("highlight"); // match all elements greater than the given index value



8.: lt (index)
Copy codeThe Code is as follows:
$ ("Tr: lt (2)"). addClass ("highlight"); // match all elements smaller than the given index value



9. header
Copy codeThe Code is as follows:
$ (": Header"). addClass ("highlight"); // matches title elements such as h1, h2, and h3.

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.