$(function () {$("ul li").addClass(function (i) { return i % 6 == 5 ? "ab" : ""; });// 隔6行 加空白。或者加虚线$(".imglist li").after(function (i) {var css = "";if (i % 3 == 2) {css = "<div class="dashed clear" ></div>";}return css;}); //图片列表photo.html 隔3行 虚线});i 是 <li>的索引号,从0开始
//方法一:jQuery(document).ready(function () {var NewUL = jQuery(".photo_list ul li");for (var i = 0; i < NewUL.length; i++) {if ((i + 1) % 3 == 0) {NewUL.eq(i).after("<li class="photo_space"></li>");}}$(".photo_list li:last").css("border-bottom", "none");})
.ab{ height:80px;}.dashed{border-bottom:1px dashed #b9c3c7;padding-bottom:10px;margin-bottom:10px}.clear{clear:both}.imglist ul li {text-align:center;line-height:25px;float:left}
以上这篇jquery li标签 隔若干行加空白或者加虚线的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。