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'); 

http://jsfiddle.net/lvm3t/

update according comment:

if want select 2 first elements, can use slice method:

$('#container img').slice(0, 2); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -