jquery $.inArray Method with Example

Today, We want to share with you jquery $.inArray Method with Example.In this post we will show you jquery inarray vs indexof, hear for jquery inarray if statement we will give you demo and example for implement.In this post, we will learn about jquery inarray compatibility with an example.

jquery $.inArray Method with Example

There are the Following The simple About jquery $.inArray Method with Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery get array index by value, so the jquery check key exists in array for this example is following below.

Also Read :  CRUD operation using AngularJS and WebAPI in ASP.NET WebForm

Example 1: jquery inarray jquery demo

using $.inArray

var myrank = [ 111, 211, 311, 511, 114 ];
 
if ( $.inArray( 114, myrank ) !== -1 ) {
   console.log( "myrank found it!" );
}

var programming_lang = ['PHP', 'AngularJS', 'Codeigniter'];

console.log($.inArray('AngularJS', programming_lang));

if ($.inArray('AngularJS', programming_lang) >= 0) {
  console.log('AngularJS is exist!');
}else {
  console.log('AngularJS does not exist!');
}

Full Source Code Example

Jquery check if value exists in Array Example

<!DOCTYPE html>
<html>
<head>
    <title>Jquery check if value exists in Array Example - pakainfo.com</title>
    <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
    var programming_lang = ['PHP', 'AngularJS', 'Codeigniter'];
    console.log($.inArray('AngularJS', programming_lang));

    if ($.inArray('AngularJS', programming_lang) >= 0) {
      console.log('AngularJS is exist!');
    }else {
      console.log('AngularJS does not exist!');
    }
</script>
</body>
</html>

Web Programming Tutorials Example with Demo

Read :

Also Read :  Like Dislike system with PHP and MySQL

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jquery $.inArray Method with Example.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.