get position of .length jquery -
i using $('.gallery img').click
call function , using .length
value in comparison, need position of img in div. .gallery div array , img in number "0 9" click third img , 2 or fifth 1 , 4.
you can use jquery index
method getting index of clicked image element in jquery collection:
var $img = $('.gallery img').on('click', function() { var = $img.index(this); });
if image wrapper has image children can can use index
method without passing element:
var = $(this).index();
Comments
Post a Comment