Run function if specific word is found in array using $.inArray() - Javascript jQuery

Javascript examples for jQuery:Array

Description

Run function if specific word is found in array using $.inArray()

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> 
  <script src="https://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> 
  <script>
    var co = ["test"];
    $(document).ready(function(){
      $(".finish").click(function(){
        if ($.inArray("test", co) >= 0) {
          console.log($.unique(co));
          return false;//from  w  w w. j  a v  a2s . c  o  m
        }
      });
    });

      </script> 
 </head> 
 <body> 
  <div class="finish">
    test
  </div>  
 </body>
</html>

Related Tutorials