magritton
11/7/2016 - 3:57 AM

This is a JavaScript prototype that has a contains method. This is attached to an HTML select element.

This is a JavaScript prototype that has a contains method. This is attached to an HTML select element.

//this add the contains method to the select element
HTMLSelectElement.prototype.contains = function( value ) {
    for ( var i = 0, l = this.options.length; i < l; i++ ) {
        if ( this.options[i].value == value ) {
            return true;
        }
    }
    return false;
}