Remove first occurence in array using jQuery -
i trying delete array first occurence, not elements searched element array like:
groupedobjects: [ { value: 125, currency: "eur" }, { value: 100, currency: "usd" }, { value: 100, currency: "usd" }, { value: 320, currency: "ron" } ]
the code using solve problem is:
var newarr = $.grep(amount, function(item, idx) { return item.currency == currency || item.value == val; }, true); amount = newarr;
the problem code using it, delete occurences found, not first 1 can me?
$.each(amount, function(idx, item) { if (item.currency == currency || item.value == val) { amount.splice(idx, 1); // remove current item return false; // end loop } });
Comments
Post a Comment