JQUERY TO CHECK WHETHER VALUE EXISTS IN ARRAY OR NOT?

Rate this post

JQUERY TO CHECK WHETHER VALUE EXISTS IN ARRAY OR NOT?

In this Post We Will Explain About is JQUERY TO CHECK WHETHER VALUE EXISTS IN ARRAY OR NOT? With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Check if value exists in Array – jQuery and JavaScript Example

Free Live Chat for Any Issue

In this post we will show you Best way to implement inArray – checking for a value in an array, hear for How to Check Value Exist in Array using Javascript/Jquery with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Read Also:  Json object check if value exists Example

How to Check if A Value exists in Array Jquery

In this Example,First of all Add or Inluce External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priorty set.After that Include your relavant CSS Class.

jQuery’s Introduction: In this Post We Are going to Learn how to find some whether specified data value/people check conditions exists in array or not using simple javascript’s based jQuery’s using $.inArray() as well as javascript’s indexOf() methods.

The $.inArray() function is also simple similers to JavaScripts native based .indexOf() function in that it simple returns -1 when it doesn’t exists or not find a particuler value match and returns the array index of the HTML element if found.

Read Also:  jQuery mouseover() Events Examples (jquery mouseover event)

index.html

<html>
<head>
    <title>How to Check Value Exist in Array using Javascript/Jquery</title>
<script type="text/javascript">
        function check_people() {          
            var officer_list = ['Jawaharlal Nehru', 'Gulzarilal Nanda', 'Lal Bahadur Shastri', 'Indira Gandhi', 'Morarji Desai', 'Charan Singh', 'Indira Gandhi', 'Rajiv Gandhi'];
            var people = $('#peopleslogan').val();
         
if ($.inArray(people, officer_list) != -1) // or if (officer_list.indexOf(people) != -1)
            {
                $('#display_msg').html(people + ' found');
            }
            else {               
                $('#display_msg').html(people + ' not found');
            }
        }
    </script>
</head>
<body>
    <input type="text" id="peopleslogan" />
       <button type="button" onclick="check_people();">Submit</button><br /><br />
 <span id="display_msg"></span>
</body>

</html>

You are Most welcome in my youtube Channel Please shubscibe my channel. and give me feedBackMore Details……
Angularjs Example

Read Also:  Send Forgot password by mail or message in PHP

Example

Download

I hope you have Got What is javascript – Jquery, checking if a value exists in array or not And how it works.I would Like to have FeaeBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.