Home > Article > Web Front-end > jQuery adds line segments at intervals of a certain number of elements
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:
<!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>
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!