I have a data structure like this:
var r =
{
"abc": ["a1","a2","a3"] ,
"xyz": ["x1","x2","x3"]
}
I am accessing these elements like this
jQuery.each(r,function(index,ele){
alert(ele); // values like a1,a2,a3 in ele -loop
});
I am getting values a1, a2, a3 in elements in ele variable.
I want to access values abc and xyz.
how to access value abc in loop?
fiddle: [fiddle]: http://jsfiddle.net/ce58qutw/
eachover an object theindexandelearguments are key and value, respectively. Now you alert the value undereleargument, but you want the key, which is underindex.