jQuery

# Select all elements except the current element

Published on May 28th, 2020

If you don't want the current element to be selected in an array of elements that belongs to same class or type, just use the .not() method like the example below:


$(".btn").click(function(){$(".btn").not(this).text('selected');
});



The above code will change the text for all buttons except the current element.