Delete a selected element from an array using jQuery:
var data = [7,2, 6, 1, 8, 5, 10];
console.log(array)
var valIndex= data.indexOf(8);
if (valIndex> -1) {
array.splice(valIndex, 1);
}
console.log(data);
Output:
[7,2, 6, 1, 5, 10]
var data = [7,2, 6, 1, 8, 5, 10];
console.log(array)
var valIndex= data.indexOf(8);
if (valIndex> -1) {
array.splice(valIndex, 1);
}
console.log(data);
Output:
[7,2, 6, 1, 5, 10]
Comments
Post a Comment