Bug Tracker


Ticket #1356 (closed feature: wontfix)

Opened 7 years ago

Last modified 6 years ago

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:
Blocking: Blocked by:


<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

comment:1 Changed 6 years ago by brandon

  • Priority changed from major to minor
  • Status changed from new to closed
  • Resolution set to wontfix

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;

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.