Select input with id != value

Asked

Viewed 83 times

1

a selector like this:

$('#minhaDiv input[id!="meuId1"]');

is well comun. I wonder if it is possible to do something like:

$('#minhaDiv input[id!="meuId1" && id!="meuId8"]');

Thank you.

1 answer

3


I know two ways to do this:

$('#minhaDiv input[id!="meuId1"][id!="meuId8"]');

or

$('#minhaDiv input').filter(function(){
    var id = jQuery(this).attr('id');
    var idInvalidos = [
        'meuId1',
        'meuId8',
    ];
    return !jQuery.inArray(id,idInvalidos);
});
  • 2

    another possibility is #minhaDiv input:not(#meuId1):not(#meuId8)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.