How to Remove a Specific Element of an Array in JavaScript

It is very common use to remove a specific element of an array when we need to present all elements of an array but
there is a element or more than one to be removed. I would try to guide you with example;
Suppose there is an array;

var arrayValues = [2,3,7];
var selection = arrayValues.indexOf(3);
if (selection > -1 {
arrayValues.splice(selection, 1);

the result would be;

arrayValues= [2,7]

How To Remove A Specific Div of Same Classes in JavaScript

There are so many ways to remove a specific div or more than one div of same class or id. It is tried to present all methods.

1. You can remove first or last div of same class or id.

The following code would remove first div of same class;


Similarly when we put last instead of first, it would remove last div of same class.


Note: In above example, class is used to remove the specefic div, same can be process with same id as changing code respectively. $(‘#div-same-id:first’).remove(); and $(‘#div-same-id:last’).remove();

to be continued…..