Jquery multiple selector

I have these ugly jquery selectors.

$('div img').eq(3).css('padding-right', '0'); //multiple of 4... $('div img').eq(7).css('padding-right', '0'); $('div img').eq(11).css('padding-right', '0'); $('div img').eq(15).css('padding-right', '0'); 

I need to get all imgages in positions in 4 and several positions ...

Is there any better code than mine ?:-)

+4
source share
2 answers

Yes:

 $('div img:nth-child(4n+3)').css('padding-right', '0'); 
+8
source

You can use nth-child as shown here:

http://jsfiddle.net/YdsjY/

+1
source

All Articles