javascript - Dynamicaly add images in DIV one by one -
in have 9 images , want write jquery code add first 3 , last 3 images selected image .suppose user clicks on 4 add 1,2,3 1 class , 5,6,7, class
how this.i tried following add prev.
t.prevall().addclass('t1'); t.nextall().addclass('t2');
thanks , regards,
you can use :lt
selector:
t.nextall(':lt(3)').addclass('t2'); t.prevall(':lt(3)').addclass('t1');
update according comment:
if want select 2 first elements, can use slice
method:
$('#container img').slice(0, 2);
Comments
Post a Comment