Pierre Dommerc Pierre Dommerc - 22 days ago 4
Javascript Question

Select all buttons except one with jQuery

I have this code :

<div id="filters" class="button-group">
<button class="button is-checked" data-filter="*">Tous</button>
<button class="button" data-filter=".image">Photos</button>
<button class="button" data-filter=".movie">Vidéos</button>
<button class="button" data-filter=".text">Text Seulement</button>
<button class="button" id="sort" data-sort-value="likes">Likes</button>

I would like select all buttons from div #filters except the only one with #sort, using jQuery's selector.

Currently I have this but it doesn't work :

$('#filters').not('#sort').on( 'click', 'button', function() {

Can you help me ?


Click on button's id is not sort ...

$('#filters').on( 'click', 'button:not("#sort")', function() {