Check if a value is in an Array in jQuery

    [javascript]
    //jQuery version
    jQuery.inArray("value", arr); // Usage: if( jQuery.inArray("value", arr) != -1 ) { true };

    //Javascript version
    Array.prototype.inArray = function (value) {
    var i;
    for (i=0; i < this.length; i++) {
    if (this[i] === value) {
    return true;
    }
    }
    return false;
    };

    //[1,2,3].inArray(2) > true
    //[1,2,3].inArray(22) > false
    [/javascript]

    One Reply to Check if a value is in an Array in jQuery

    1. Arun says:

      Please give me more on this , and demo
      I need to enter 2 digit values in 30 text boxes ,again i enter same value to the same text box . How can i check this values.

    Leave a Reply