Can I use a Regular Expression within jQuery.inArray()

后端 未结 5 683
刺人心
刺人心 2021-01-07 06:42

I would like the following if statement to alert \'yes\' if \'featured\' is in array, regardless of whether it is uppercase or lowercase.

I\'m also not

5条回答
  •  时光取名叫无心
    2021-01-07 07:20

    You can use $.grep to filter the array and then check the length:

     if ( $.grep( myArray, function (e, i ){ return /featured/i.test(e); }).length > 0 )
        alert( "YES!" );
    

提交回复
热议问题