Other answers forget an important point - thismost likely, in some event callback, and this is probably a single element , therefore it is always the first element in the selection ( :eq(0)).
Therefore, each subsequent equivalent fragment will never hide anything :
$(this).not(':eq(0)').hide();
$(this).filter(':gt(0)').hide();
$(this).slice(1).hide();
I only guess the intent of OP here, but the code should probably be:
if ($(this).index('#myDiv img') > 0) $(this).hide();
source
share