Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery opposite of "starts with" selector: [^=]

I have some div tag below:

<div class="magazine"></div>
<div class="newsletter"></div> // I need to take this div
<div class="may-moon"></div>

If I needed div with class start with "ma", I would use $('div[class^="ma"]'), but what is opposite? thanks.

like image 396
Aldi Unanto Avatar asked Jun 27 '13 01:06

Aldi Unanto


2 Answers

The opposite would be to use jQuery :not():

$('div:not([class^="ma"])')
like image 50
Karl-André Gagnon Avatar answered Sep 20 '22 01:09

Karl-André Gagnon


You can use the negative filtering function "not" like this: $('div').not('[class^="ma"]'), or the negative selector ":not" like this: $('div:not([class^="ma"])') (as pointed by Karl-André Gagnon)

like image 34
jacmkno Avatar answered Sep 21 '22 01:09

jacmkno