0

I am trying to do a select all in jQuery to all those who contain a specific class. However, I want one of those elements that has the class to not be selected if it has a specific data-id, in this case data-id='162'.

This code works to check all of them, but what can I do here to not check the one that has data-id:162?

$('.elementsToCheck').attr('checked', checked)
isherwood
  • 52,576
  • 15
  • 105
  • 143
Joao Moita
  • 23
  • 2
  • 1
    assuming you used double quotes (`data-id="162"`), this shoud work: `$('.elementsToCheck:not([data-id="162"])')` – GrafiCode May 31 '22 at 19:48

0 Answers0