Pierre Dommerc Pierre Dommerc - 1 year ago 89
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 ?

Answer Source

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

$('#filters').on( 'click', 'button:not("#sort")', function() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download