ItSolutionStuff.com

JQuery Remove Multiple Values from Array Example

By Hardik Savani • July 20, 2023
jQuery

in this post, i would like to give you example of how to remove multiple element from array in jquery. we can simply remove multiple values from array in jquery. you can see simple example of remove multiple items from array in jquery.

we will use Array.prototype.remove, grep() and inArray() for removing multiple values from array in jquery. you can just see bellow example it's done. you can easily use with your jquery array.

If you want to remove single item from jquery array by value then you can follow this tutorial: How to Remove Array Element in Jquery by Value?.

So let's see bellow simple example of jquery remove multiple values from array.

Example :

<!DOCTYPE html>

<html>

<head>

<title>Jquery Remove Multiple Values from Array Example - ItSolutionStuff.com</title>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>

</head>

<body>

<script type="text/javascript">

var sites = [ "ItSolutionStuff.com", "HDTuto.com", "NiceSnippets.com", "Hackthestuff.com" ];

Array.prototype.remove = function(){

var args = Array.apply(null, arguments);

return $.grep(this, function(value) {

return $.inArray(value, args) < 0;

});

}

sitesNew = sites.remove("HDTuto.com", "NiceSnippets.com");

console.log(sitesNew);

</script>

</body>

</html>

Output:

["ItSolutionStuff.com", "Hackthestuff.com"]

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

JQuery Moment JS Subtract Hours to Datetime Example

Read Now →

JQuery Moment Subtract Year from Date Example

Read Now →

How to Print Iframe Content using Jquery?

Read Now →

JQuery Radio Button Change Event Example

Read Now →

How to Remove Element from Array in JQuery?

Read Now →

How to Get Unique Values from Array in JQuery?

Read Now →

How to Remove Key Value from Array using JQuery?

Read Now →

Javascript Convert Array into Comma Separated String Example

Read Now →

How to Get Last Element from Array using JQuery?

Read Now →

JQuery Check If Value Exists or Not in Array Example

Read Now →

How to Check Array Is Empty Or Null In Javascript?

Read Now →

Add Edit Delete Table Row Example using JQuery

Read Now →

How to Remove Empty or Null Values from Array in JQuery?

Read Now →

How to Remove Duplicate Value from Array in JQuery?

Read Now →