jQuery inArray

Example of inArray function with jQuery

by Akram kamal

JavaScript

var test = new Array('arg1', 'arg2', 'arg3');
var test2 = new Array('arg1', 'arg4');

$(document).ready(function() {
    for (var cl = 0; cl < test.length; cl++) {
        var nm_arg = test[cl];

        if ($.inArray(nm_arg, test2) === -1)
          alert(''+nm_arg+' not present!');
        else
           alert(''+nm_arg+' ------- present!');  
      }
})