I would like to display a "receptacle" after each 3 divs that are visible. Because following the filter each div is hidden or not.
I want the receptacle just after each 3 divs... but if the articles ends by one or two on the line just put a receptacle after them.
Ex: html
<div class="container">
<article style="display:block"></article>
<article style="display:block"></article>
<article style="display:none"></article>
<article style="display:block"></article>
<article style="display:none"></article>
<article style="display:block"></article>
<article style="display:block"></article>
<article style="display:none"></article>
<article style="display:block"></article>
<article style="display:block"></article>
</div>
js
jQuery(document).ready(function ($) {
$('.container > article:visible:nth-child(3n)').after('<div class="receptacle"></div>');
$('article').each(function () {
$(this).on('click', function () {
$(this).nextAll('receptacle').text('toto');
});
});
});
css
article {
float:left;
width:30%;
height:40px;
background:DeepSkyBlue;
margin:5px;
}
the fiddle: http://jsfiddle.net/XLK6z/
Thanks!