sid/js/lib/adjust.js

9 lines
378 B
JavaScript
Raw Normal View History

// on définit le "indexOf" pour <HTMLCollection> et <NodeList>
NodeList.prototype.indexOf = HTMLCollection.prototype.indexOf = function(searchedElement){
for( var i = 0 ; i < this.length ; i++ ) // on parcours la collection
// si on trouve l'élement, on retourne son rang
if( this[i] == searchedElement ) return i;
// si on a rien trouvé, on retourne -1
return -1;
};