Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p:nth-child(3n+2)").css("background-color", "yellow");
});
</script>
</head>
<body>
<p>The p:nth-child(3n+2) selects each 3rd paragraph, starting at the 2nd child element.
<div style="border:1px solid;">
  <span>This is a span element</span>
  <p>The first paragraph (and the second child in div).</p>
  <p>The second paragraph.</p>
  <p>The third paragraph.</p>
  <p>The fourth paragraph.</p>
  <p>The fifth paragraph.</p>
  <p>The sixth paragraph.</p>
  <p>The seventh paragraph.</p>
  <p>The eight paragraph.</p>
</div><br>
</body>
<!-- Mirrored from www.w3schools.com/jquery/tryit.asp?filename=tryjquery_sel_nthchild_formula by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 15:43:21 GMT -->
</html>