Bug Tracker

Ticket #1356 (closed feature: wontfix)

Opened 8 years ago

Last modified 8 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 8 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;
Note: See TracTickets for help on using tickets.