Jquery array key value by index -
Jquery array key value by index -
i seek keys , values array. don't understand how value/key index...
here script (i force keys , values in loop seek value corresponding position in array):
var imgarr = []; imgarr.push({"src":$(this).find('.lightbox').data('img-src'),"title":$(this).find('.lightbox').data('img-title')}); var index = 3; $(lbimage).attr('src', imgarr[index].src);
with console.log(imgarr) get:
[object, object, object, object, object, object, object, object, object] 0: object src: "http://ddd/wp-content/uploads/sites/2/2013/12/stray-cat.jpg" title: "stray cat" __proto__: object 1: object src: "http://ddd/wp-content/uploads/sites/2/2013/12/birds.jpg" title: "birds" __proto__: object 2: object 3: object 4: object 5: object 6: object 7: object 8: object length: 9 __proto__: array[0]
jquery arrays key associative-array
Comments
Post a Comment