For loop with count Demo : http://jsfiddle.net/xsTRK/1/