jquery map - assign the return value as a key of the receiving object -


i have:

    <img class="images" src="src1">     <img class="images" src="src2">     <img class="images" src="src3">     <img class="images" src="src4">  var pictures = $(".images").map(function(){     return $(this).attr("src"); }) 

the code above creates new pictures array. can think of efficient way create new pictures object using jquery map function. like:

var pictures[key] = $(".images").map(function(){     var key = $(this).attr("src");     return key; }) 

... directly assign return value key pictures object. there way?

can't iterate collection?

var picobj = {}; $(".images").each(function() {     picobj[$(this).attr("src")] = '...'; }); 

(demo - print console)


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -