JQuery - 每隔x次将框插入墙中

时间:2022-05-01 02:30:44

I bought this plugin: http://goo.gl/FnMjAa

我买了这个插件:http://goo.gl/FnMjAa

this is a social stream in a wall.

这是一堵墙上的社交流。

and i want to add custom massege after every x boxes.

我想在每个x框之后添加自定义massege。

I mean I need to to insert a box after every X Boxes.

我的意思是我需要在每个X Box之后插入一个盒子。

can i do it?

我可以做吗?

1 个解决方案

#1


0  

I would use nth-child selector to insert something after each nth element. Consider this

我会使用nth-child选择器在每个第n个元素之后插入一些东西。考虑一下

// Insert after every 5th
$('.box:nth-child(5n)').after(function() {
    return '<div class="message">Message: after ' + $(this).data('id') + '</div>';
});

Demo: http://jsfiddle.net/Su3c2/1/

Maybe it will work for you.

也许它会对你有用。

#1


0  

I would use nth-child selector to insert something after each nth element. Consider this

我会使用nth-child选择器在每个第n个元素之后插入一些东西。考虑一下

// Insert after every 5th
$('.box:nth-child(5n)').after(function() {
    return '<div class="message">Message: after ' + $(this).data('id') + '</div>';
});

Demo: http://jsfiddle.net/Su3c2/1/

Maybe it will work for you.

也许它会对你有用。