


jQuery Let's learn CSS selector parity matching nth-child(even)_jquery
In this regard, I will briefly introduce the usage of nth-child() in the CSS3 standard:
CSS3 pseudo-class selector: nth-child()
A brief summary of nth-child() several uses.
First: nth-child(number) directly matches the number-th element. The parameter number must be an integer greater than 0.
(EG) li:nth-child(3){background:orange;}/*Set the background of the 3rd LI to orange*/
Second: nth-child( an) matches all elements that are multiples of a. The letter n in parameter an cannot be omitted. It is a symbol of multiple writing, such as 3n, 5n.
(EG) li:nth-child(3n){background:orange;}/*Set the background of the 3rd, 6th, 9th,..., all multiples of 3 LI to orange*/
Third: nth-child(an b) and :nth-child(an-b) First group the elements, each group has a, b is the serial number of the member in the group, the letter n and the plus sign cannot be defaulted, The position cannot be interchanged, which is a sign of this writing method, where a and b are both positive integers or 0. Such as 3n 1, 5n 1. But the plus sign can be changed to a minus sign, which matches the a-bth one in the group. (In fact, an can also be preceded by a negative sign, but leave it to the next part.)
(EG)li:nth-child(3n 1){background:orange;}/*matches the 1st, 4th, and 7th ,..., the 1st LI in each group of 3*/
li:nth-child(3n 5){background:orange;}/*matches the 5th, 8th, 11th,..., from the 5th, 8th, 11th,... The first LI*/
li:nth-child(5n-1){background:orange;}/*matches the 5th-1=4 and the 10th-1= 9. ..., multiples of the 5th minus 1 LI*/
li:nth-child(3n±0){background:orange;}/*equivalent to (3n)*/
li:nth-child (±0n 3){background:orange;}/*Equivalent to (3)*/
Fourth: nth-child(-an b) One negative and one positive here cannot be defaulted, otherwise it will be meaningless. This is similar to :nth-child(an 1), both match the first one, but the difference is that it counts backwards, starting from the b-th child and counting back, so it will match at most no more than b.
(EG) li:nth-child(-3n 8){background:orange;}/*matches the 8th, 5th and 2nd LI*/
li:nth-child(-1n 8) {background:orange;}/* or (-n 8), matches the first 8 (including the 8th) LI. This is more practical and is often used to limit the first N matches */
Fifth: nth-child(odd) and :nth-child(even) match elements with odd and even numbers respectively. The odd number (odd) has the same result as (2n 1); the even number (even) has the same result as (2n 0) and (2n).
Use this method in jQuery to achieve the striped effect:
$("table tr:nth-child(even)").addClass("striped");
even can be replaced by other parameters, and all of the five situations described above are acceptable. The addClass("striped") after
striped is a CSS class name.
While learning jquery, I also learned some selectors in CSS.
Hope you can stick with it.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to adjust WordPress themes to avoid misaligned display requires specific code examples. As a powerful CMS system, WordPress is loved by many website developers and webmasters. However, when using WordPress to create a website, you often encounter the problem of theme misalignment, which affects the user experience and page beauty. Therefore, it is very important to properly adjust your WordPress theme to avoid misaligned display. This article will introduce how to adjust the theme through specific code examples.

H5 page production refers to the creation of cross-platform compatible web pages using technologies such as HTML5, CSS3 and JavaScript. Its core lies in the browser's parsing code, rendering structure, style and interactive functions. Common technologies include animation effects, responsive design, and data interaction. To avoid errors, developers should be debugged; performance optimization and best practices include image format optimization, request reduction and code specifications, etc. to improve loading speed and code quality.

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

jQuery is a popular JavaScript library widely used in web development. During web development, it is often necessary to dynamically add new rows to tables through JavaScript. This article will introduce how to use jQuery to add new rows to a table, and provide specific code examples. First, we need to introduce the jQuery library into the HTML page. The jQuery library can be introduced in the tag through the following code:

The :not() selector can be used to exclude elements under certain conditions, and its syntax is :not(selector) {style rule}. Examples: :not(p) excludes all non-paragraph elements, li:not(.active) excludes inactive list items, :not(table) excludes non-table elements, div:not([data-role="primary"]) Exclude div elements with non-primary roles.
