This is the blog for getting Idea regarding PHP, Magento, jQuery and JavaScript for Customization.

Saturday, 6 June 2015

jQuery : Remove or Delete value from the array

Hello Friends,

    Here, Using jQuery remove the Value and index from the array !

/*Remove Values and index from Array*/
jQuery
var sample_array = new Array('Apple','Banana','Mango','Lemon');
var val = "Mango";

remove_item(sample_array,val);

var remove_item = function (arr, value) {
    var b = '';
    for (b in arr) {
        if (arr[b] === value) {
            arr.splice(b, 1);
            break;
        }
    }
    return arr;
}
/*Result will be*/
/*Array['Apple','Banana','Lemon']*/

I hope this will helpful to you !
Thanks 
,

No comments:

Post a Comment