开发者

Get value of "data"

I need to figure out the value of data strings with jquery, for example like this:

 { label: "Beginner",  data: 2},
 { label: "Advanced",  data: 12开发者_StackOverflow社区},
 { label: "Expert",  data: 22},

to add them up.

Something like:

var sum = data1+data2+data3;
alert(sum);

So the result for this example would be 36.

Appreciate your help!


Something like this?:

var data = [
   { label: "Beginner",  data: 2},
   { label: "Advanced",  data: 12},
   { label: "Expert",  data: 22} 
]
var sum = 0;

for each (var d in data) {
    sum += d.data;
}

alert(sum);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜