Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple selector jquery

i've got this 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 have to get all imgages in positioned in 4^ and multiple-of-4 positions...

is there a better code than mine? :-)

like image 588
Roberto Avatar asked Jan 20 '23 22:01

Roberto


1 Answers

Yes:

$('div img:nth-child(4n+3)').css('padding-right', '0');
like image 52
Pointy Avatar answered Feb 03 '23 04:02

Pointy