javascript - jQuery: Select all elements with a given class, return their product (multiplication result)? -
i have unknown number of values (coming server-side code) contained in spans class num
. need product of of these values.
i tried alert(multiply(jquery('.num').val());
no luck. know it's simple, cannot wrap head around it. missing?
a simple procedural version be
var result = 1; $('.num').each(function() { result *= parsefloat($(this).text()); }); console.log(result);
Comments
Post a Comment