nth-child() css
/* Selects the second <li> element in a list */
li:nth-child(2) {
color: lime;
}
/* Selects every fourth element
among any group of siblings */
:nth-child(4n) {
color: lime;
}
nth-child() css
/* Selects the second <li> element in a list */
li:nth-child(2) {
color: lime;
}
/* Selects every fourth element
among any group of siblings */
:nth-child(4n) {
color: lime;
}
css nth child
/* Select the first list item */
li:nth-child(1) { }
/* Select the 5th list item */
li:nth-child(5) { }
/* Select every other list item starting with first */
li:nth-child(odd) { }
/* Select every 3rd list item starting with first */
li:nth-child(3n) { }
/* Select every 3rd list item starting with 2nd */
li:nth-child(3n - 1) { }
/* Select every 3rd child item, as long as it has class "el" */
.el:nth-child(3) { }
css nth-child
/* Select the first list item */
li:nth-child(1) { }
/* Select odd list items */
li:nth-child(odd) { }
/* Select even list items */
li:nth-child(even) { }
/* Select each list item every 3 (3,6,9...) */
li:nth-child(3n) { }
/* Select each list item every 3 starting from the fourth (4,7,10...) */
li:nth-child(3n+1) { }
nth child
/* Selects the second <li> element in a list */
li:nth-child(2) {
color: lime;
}
/* Selects every fourth element
among any group of siblings */
:nth-child(4n) {
color: lime;
}
div nth child
div:nth-child(2) {
background: red;
}
:nth-child(2)
//https://www.sitepoint.com/comprehensive-jquery-selectors/
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>nth-child demo</title>
<style>
div {
float: left;
}
span {
color: blue;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<div>
<ul>
<li>John</li>
<li>Karl</li>
<li>Brandon</li>
</ul>
</div>
<div>
<ul>
<li>Sam</li>
</ul>
</div>
<div>
<ul>
<li>Glen</li>
<li>Tane</li>
<li>Ralph</li>
<li>David</li>
</ul>
</div>
<script>
/*This one is a bit complex.
It can accept a variety of values
as parameter like a number greater than or equal to 1,
the strings even and odd or an equation like 4n+1*/
$( "ul li:nth-child(2)" ).append( "<span> - 2nd!</span>" );
//karl - 2nd
//Tane - 2nd
</script>
</body>
</html>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us