jQuery inArray() Function Example

Hello friends today you will learn jQuery inArray() function example. The jquery inarray function is used to check value exists or not in array. Here i will show how to use inarray function in jquery.

Check if value already exists in array jquery

<!DOCTYPE html>
<title>jQuery inArray check if value exists in Array</title>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
var myArray = ['React', 'jQuery', 'Laravel'];
if (jQuery.inArray('jQuery', myArray) >= 0) {
console.log('jQuery is exist!');
}else {
console.log('jQuery does not exist!');

I hope you understand of jquery inarray function and it can help you…

Read Also :  How To Validate Upload File Type Using JavaScript