$('#wrapper a').each(function(i,e){
if (((i+1) % 3) == 0)
$(this).after('<p>Hello, world.</p>');
});
Use the .each"i" option , which gives you the index of the item. Than you can use Modulo to get the 3rd element and add.
Working example: http://www.jsfiddle.net/hd7FP/1/
at that moment an alternative solution is just shown
source
share