HDTuto.com

Jquery Delete Element from Array by Index Example



Today our leading topic is jquery remove key from array. This post will give you simple example of jquery remove key value from object. you will learn jquery remove object from array by key value. We will use jquery remove value from array by index.

You can use any one as you need. we can easily delete key value from array using splice function of js array. if you have jquery array object and you need to remove it then you can remove it using "delete".

Let's see both example so it can help you for deleting key value from jquery array. so let's see that:

Example 1:

<!DOCTYPE html>

<html>

<head>

<title>How to remove key value from array in JQuery? - HDTuto.com</title>

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>

</head>

<body>

<script type="text/javascript">

var myArray = ['PHP', 'Laravel', 'Codeigniter'];

myArray.splice(1, 1);

console.log(myArray);

</script>

</body>

</html>

Output:

Array(2)

0: "PHP"

1: "Codeigniter"

Example 2:

<!DOCTYPE html>

<html>

<head>

<title>How to remove key value from array in JQuery? - HDTuto.com</title>

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>

</head>

<body>

<script type="text/javascript">

var myArray = { php: "PHP", laravel: "Laravel", codeigniter: "Codeigniter" };

delete myArray['laravel'];

console.log(myArray);

</script>

</body>

</html>

Output:

Object

codeigniter: "Codeigniter"

php: "PHP"

I hope it can help you...




May 2, 2020 | Category : JQuery



Blog Search