Answers for "nth-child(2n + 3)"

CSS
6

nth-child(2n+1)

/* 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) { }
Posted by: Guest on May-30-2020
0

: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>
Posted by: Guest on August-22-2021

Browse Popular Code Answers by Language