clock  Mon - Sun 8.00 AM - 8.00 PM
fb
instagram
play store
pinterest

How to Remove Multiple Elements From Array Using Value in jQuery

writter  Sumit Dey Sarkar
Date  22 Aug 2022
Language  JQuery
How to Remove Multiple Elements From Array Using Value in jQuery

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