Bug Tracker

Opened 16 years ago

Closed 15 years ago

#1356 closed feature (wontfix)

May add a sum() function ?

Reported by: Heflying Owned by:
Priority: minor Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: function sum Cc:
Blocked by: Blocking:


<div>1</div> <div>3</div> <div>6</div>

jQuery Code: $("div").sum(); returns 10

it's useful (like XSLT's sum() function)

Change History (1)

comment:1 Changed 15 years ago by brandon

Priority: majorminor
Resolution: wontfix
Status: newclosed

This will be best served as a plugin. The plugin code might look something like this (untested).

$.fn.sum = function() {
    var sum = 0;
    this.each(function() {
        sum += parseInt(this.innerText) || 0;
    return sum;
Note: See TracTickets for help on using tickets.