Answers for "nth:child(third)"

CSS
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