jquery <li>标签 隔若干行加空白或者加虚线的方法
实例如下:
$(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}
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17