jquery 对进行分组
发布网友
发布时间:2022-05-18 09:04
我来回答
共2个回答
热心网友
时间:2022-05-18 10:34
<html>
<body>
<ul>
<li>xxxxxx1</li>
<li>xxxxxx2</li>
<li>xxxxxx3</li>
<li>xxxxxx4</li>
<li>xxxxxx5</li>
<li>xxxxxx6</li>
<li>xxxxxx7</li>
<li>xxxxxx8</li>
<li>xxxxxx9</li>
<li>xxxxxx10</li>
<li>xxxxxx11</li>
<li>xxxxxx12</li>
<li>xxxxxx13</li>
<li>xxxxxx14</li>
<li>xxxxxx15</li>
</ul>
<ul id="ul0"></ul>
<ul id="ul1"></ul>
<ul id="ul2"></ul>
</body>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("li").each(function(i){
var id = "ul"+parseInt(i/10);
$(this).appendTo("#"+id);
});
});
</script>
</html>
热心网友
时间:2022-05-18 11:52
循环