Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
How to give a condition check in the `is()` in jquery

I need to check if any one of the array element satisfies the given condition. but I get an error that "is is not defined".

var tempfLength = tempfArray.length;
for(var i=tempfLength-2;i> -1;i--){
   alert(tempfArray[i]);
   if((tempfLength >length)&&(is(tempfArray[i]==parentName))){
     $(this).hide('str');
   }
}
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Change the following line:

if((tempfLength >length)&&(is(tempfArray[i]==parentName)))
{

}

to

if( (tempfLength >length) && (tempfArray[i] == parentName) )
{
    // Do something here
}

Note:

  • You can put multiple condition using && or ||
  • You cannot compare 2 objects using ==
over 4 years ago · Santiago Trujillo Relatório

0

the is() function is used like:

if((tempfLength >length)&&(parentName.is(tempfArray[i])))
{

}

Read the documentation:http://api.jquery.com/is/

Make sure that both parentName and tempfArray[i] are jquery objects

over 4 years ago · Santiago Trujillo Relatório

0

is is not definded.

This error says means that the function is() isn't available in the global context you are calling it.

As i understood the issue you can try this with Array.prototype.find():

var $this = $(this); // <----make sure to cache it as in the array this doesn't belong to
var tempfLength = tempfArray.length; //`----what you think.
for(var i=tempfLength-2;i> -1;i--){
    alert(tempfArray[i]);
    if((tempfLength >length)&&(tempfArray.find(function(item){item === parentName})))){
      $this.hide('str');
    }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda