Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!