clock  Mon - Sun 8.00 AM - 8.00 PM
mail  edu@teknowize.com
fb
instagram
play store
pinterest

How to Remove Multiple Elements From Array Using Value in jQuery

  Sumit Dey Sarkar
  22 Aug 2022
  JQuery
Imperial Advance Hero Image

How to Remove Multiple Elements From Array Using Value in jQuery

In this article we will learn how to remove multiple elements from array using value in jQuery.

Here we will use Array.prototype.remove, grep(), and inAray() to remove multiple values from array using jQuery,

lets see the example - 

 

How to remove multiple values from array by value using jQuery

<!DOCTYPE html>
<html>

<head>
  <title>How to Remove Multiple Elements From Array Using Value in jQuery</title>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>

<body>
  <p id="remainigValues"></p>
  <script>
    var devlompentSites = ["teknowize.com", "W3School.com", "tutorialpoint.com", "stackoverflow.com"];

    Array.prototype.remove = function () {
      var args = Array.apply(null, arguments);

      return $.grep(this, function (value) {
        return $.inArray(value, args) < 0;
      });
    }
    remainingDevlompentSites = devlompentSites.remove("W3School.com", "tutorialpoint.com");
    $('#remainigValues').text(remainingDevlompentSites);
  </script>

</body>

</html>

 

Output

teknowize.com,stackoverflow.com