Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda