How to delete elements from a jQuery collection?

Asked

Viewed 126 times

-1

For example: I want to give one .fadeOut() throughout body, but with the exception of some element, such as a div. Can this be done? How?

1 answer

7


With jQuery you can use the function not(). It allows you to select a larger group of objects and remove from them the ones you don’t want.

For example:

// seleciona todas as divs exceto as que tem a classe classe1
$('div').not('.classe1') 
// seleciona todas as `<option>` exceto as selecionadas
$('option').not(':selected')
  • Thank you, Ricardo!

  • Thanks bro, I didn’t know that!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.