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.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

Python is more suitable for data science and machine learning, while JavaScript is more suitable for front-end and full-stack development. 1. Python is known for its concise syntax and rich library ecosystem, and is suitable for data analysis and web development. 2. JavaScript is the core of front-end development. Node.js supports server-side programming and is suitable for full-stack development.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),