Check if value exists in array jquery - Solved

Introduction: In this tutorial, I am going to discuss about to check if the value exists in an array or not using jquery. The whole process done under the  <script></script> tag. Let's see. Check if the value already exists in array jquery 

1. Make a function name like valexixts.
2. Declare an array[] of var type.
3. Add Jquery Library CDN link.

Coding Part:

<script src=""></script>
<script type="text/javascript">
        function valexixts() {          
            var items = ['bat''ball''shirt''chair' 'fridge''tv'];
            var item = $('#txtItem').val();
if ($.inArray(item, items) != -1) 
                $('#lblmsg').html(item + ' found');
            else {               
                $('#lblmsg').html(item + ' not found');
    <input type="text" id="txtcheck" />
       <button type="button" onclick="valexixts();">Check</button><br />
 <span id="lblmsg"></span>