Array.filter()
non è incluso in Internet Explorer fino alla versione 9.
È possibile utilizzare questo per la sua attuazione:
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp */)
{
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
Da: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
, ovvero dal momento che si sta utilizzando jQuery, è possibile per prima cosa avvolgere la matrice in un oggetto jQuery:
songs = $(songs).filter(function(){
return this.album==album;
});
ho inviato la mia risposta prima ho visto Paolo. Le canzoni sono un array o un oggetto jQuery? – Dennis