This time I will bring you jQuery to add a line segment to a certain number of elements. jQuery to add a line segment to a certain number of elements. Notes What are the following? Here is a practical case, let’s take a look.
The screenshot of the running effect is as follows:

The specific code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <!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>jQuery每隔10条加一条线</title>
<script language= "JavaScript" src= "jquery-1.7.2.min.js" ></script>
<script language= "JavaScript" type= "text/JavaScript" >
$(document).ready( function (){
$( ".list2 li:nth-child(10n)" ).after( '<li style="margin:10px 0px;border-bottom:1px dashed #ccc;"></li>' );
});
</script>
</head>
<body>
<style>
li{ list-style-type: none;}
</style>
<ul class = "list2" >
<li>001</li>
<li>002</li>
<li>003</li>
<li>004</li>
<li>005</li>
<li>006</li>
<li>007</li>
<li>008</li>
<li>009</li>
<li>010</li>
<li>011</li>
<li>012</li>
<li>013</li>
<li>014</li>
<li>015</li>
<li>016</li>
<li>017</li>
<li>018</li>
<li>019</li>
<li>020</li>
<li>021</li>
<li>022</li>
<li>023</li>
<li>024</li>
<li>025</li>
<li>026</li>
<li>027</li>
<li>028</li>
<li>029</li>
<li>030</li>
<li>031</li>
<li>032</li>
</ul>
</body>
</html>
|
Copy after login
I believe you have mastered the method after reading the case in this article, more Please pay attention to other related articles on the php Chinese website!
Recommended reading:
What are the methods of appending elements in jquery
How does jquery ajax implement paging function
The above is the detailed content of jQuery adds line segments at intervals of a certain number of elements. For more information, please follow other related articles on the PHP Chinese website!