I recently created a code snippet to enhance the functionality of the HTMLOptionsCollection object:
HTMLOptionsCollection.prototype.contains = HTMLOptionsCollection.prototype.contains ||
function(otherOption) {
for (var i = 0; i < this.length; i++) {
if (this[i].value === otherOption.value) {
return true;
}
}
return false;
};
While it works perfectly in Firefox and Opera, I encountered issues in IE9 and Google Chrome where an error "Uncaught ReferenceError: HTMLOptionsCollection is not defined" appears.
Could someone advise me on how to resolve this issue? Am I missing something or is there a different approach I should take?