Which one to use .not or :eq

$('select').parent().find('option:eq(0)').prop('selected', true);

I want to select zero so seems works. So what to do if zero selected.

I try

.is(':not(:eq(0)'); //work

.not(':eq(0)'); //work

Whitch more useful? Whitch to use? And why?


I’m no jQuery expert, so I’m happy to be corrected if I’m wrong, but as far as I can tell there’s no real difference except for readability - so pick the one you like the look of the most.

In your example I prefer .not() simply because it’s less typing and fewer parentheses to parse when reading it.

Glancing at the jQuery docs, this might be something to consider:

As of jQuery 3.4 , the :eq pseudo-class is deprecated. Remove it from your selectors and filter the results later using .eq() .