Site icon Sibeesh Passion

Delete an element from an array in jQuery using the index

This will solve you to delete an element from an array in JQuery using the index

Consider following is my array
[js]
localHeaderColumnArray: Array[2]
0: "f"
1: "g"
length: 2
[/js]

To delete an element
[js]
delete localHeaderColumnArray[$(this).index()] ;
[/js]
Since I am using it in a click event of an li, I used $(this).index(). You can change it as
[js]
delete localHeaderColumnArray[$(this).index()] ;
[/js]

Exit mobile version