Initially all divs are having style display none property. I am enabling the divs by jquery show method if there is any content inside them,
I want to find the divs which do not have style display:none, and after every second active div,
I want to insert a css for page-break-after:always for print purpose. I want to have only 2 divs in one page when user prints.
so in this example, I want to insert css for page break on par4, and par8
(so in short find the divs which do not have style display none and insert a style for page break on every second div)
<div id="parent">
<div class="flip" id="par1" style="display:none;">empty</div>
<div class="flip" id="par2">Image/content</div>
<div class="flip" id="par3" style="display:none;">empty</div>
<div class="flip" id="par4">Image/content</div>
<div class="flip" id="par5" style="display:none;">empty</div>
<div class="flip" id="par6">Image/content</div>
<div class="flip" id="par7" style="display:none;">empty</div>
<div class="flip" id="par8">Image/content</div>
<div class="flip" id="par10" style="display:none;">empty</div>
</div>
Here:
Live demo: http://jsfiddle.net/KxGKG/2/
Although I recommend setting a CSS class, instead of writing the style inline. It is easier to set/unset classes, than styles directly.