:nth-child means matching the sub-elements below it: nth-child(Xn+Y) means starting from the Yth one. Increasing X can have: nth-child(3n+10) means starting from the 10th one. , 10, 13, 16, 19...:nth-child(3n), then Y=0, which can be omitted, indicating starting from 0, 0, 3, 6, 9...
I hope to You are helpful: Child element
:nth-child(index/even/odd/equation)
matches the Nth child or odd-even element under its parent element
Difference: ':eq(index)' only matches one element , and this one will match child elements for every parent element. :nth-child starts from 1, and :eq() starts from 0!
You can use ::nth-child(even), :nth-child(odd), :nth-child(3n), :nth-child(2), :nth-child(3n+1) , :nth-child(3n+2)
index (Number): The serial number of the element to be matched, starting from 1
Example finds the second li
# in each ul
##
<ul><li>John</li> <li>Karl</li> <li>Brandon</li></ul> <ul><li>Glen</li> <li>Tane</li> <li>Ralph</li></ul>Code:
$("ul li:nth-child(2)")
Result:
<li>Karl</li>, <li>Tane</li>
nth-child(3n+1) What does it mean?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=" http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="jquery-1.2.6.js" type="text/javascript" language="javascript"></script> <style type="text/css"> <!-- --> </style> <script type="text/javascript" language="javascript" > <!-- $(document).ready(function (){ $("#nav li:nth-child(3n+2) a").each(function(){ alert($(this).text()); }); }); --> </script> </head> <body> <ul id="nav"> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">6</a></li> <li><a href="#">7</a></li> <li><a href="#">8</a></li> <li><a href="#">9</a></li> <li><a href="#">10</a></li> </ul> </body> </html>“:nth-child means matching the child elements below it: nth-child(Xn+Y) means starting from the Yth one, and increasing X can have:nth-child(3n+10) means Starting from the 10th one, 10, 13, 16, 19...:nth-child(3n) means Y=0, which can be omitted, meaning starting from 0, 0, 3, 6, 9..." This person answered The problem is, it seems that the minimum parameter of nth-child is also 1, and it starts from 1, not from 0.
The above is the detailed content of What does nth-child(3n) mean in jquery?. For more information, please follow other related articles on the PHP Chinese website!

实现方法:1、用“$("img").delay(毫秒数).fadeOut()”语句,delay()设置延迟秒数;2、用“setTimeout(function(){ $("img").hide(); },毫秒值);”语句,通过定时器来延迟。

修改方法:1、用css()设置新样式,语法“$(元素).css("min-height","新值")”;2、用attr(),通过设置style属性来添加新样式,语法“$(元素).attr("style","min-height:新值")”。

区别:1、axios是一个异步请求框架,用于封装底层的XMLHttpRequest,而jquery是一个JavaScript库,只是顺便封装了dom操作;2、axios是基于承诺对象的,可以用承诺对象中的方法,而jquery不基于承诺对象。

增加元素的方法:1、用append(),语法“$("body").append(新元素)”,可向body内部的末尾处增加元素;2、用prepend(),语法“$("body").prepend(新元素)”,可向body内部的开始处增加元素。

删除方法:1、用empty(),语法“$("div").empty();”,可删除所有子节点和内容;2、用children()和remove(),语法“$("div").children().remove();”,只删除子元素,不删除内容。

去掉方法:1、用“$(selector).removeAttr("readonly")”语句删除readonly属性;2、用“$(selector).attr("readonly",false)”将readonly属性的值设置为false。

on()方法有4个参数:1、第一个参数不可省略,规定要从被选元素添加的一个或多个事件或命名空间;2、第二个参数可省略,规定元素的事件处理程序;3、第三个参数可省略,规定传递到函数的额外数据;4、第四个参数可省略,规定当事件发生时运行的函数。

方法:1、用hide(),语法“$("textarea").hide()”;2、用slideUp(),语法“$("textarea").slideUp()”;3、用fadeOut(),语法“$("textarea").fadeOut()”。


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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools
