用另一个元素"包装"图像:
是的,非常简单:
// document.ready
$(function(){
$("#yourList img:nth-child(5)").wrap("<div class='image-wrapper'></div>");
});
Run Code Online (Sandbox Code Playgroud)
将每个第五个图像强制到下一行
// document.ready
$(function(){
$("#yourList img:nth-child(5)").css('clear','left');
});
Run Code Online (Sandbox Code Playgroud)
这也可以在您的CSS中完成,但nth-child并非所有浏览器都支持:
#yourList img:nth-child(5){
clear: left;
}
Run Code Online (Sandbox Code Playgroud)