getElementsByAttributeName

by Felipe Alfaro

HTML

<div id="prot">
    <input data-filter>
    <input>
    <input data-filter>
    <input data-filter>
</div>

JavaScript

Object.prototype.getElementsByAttributeName = function(attribute){
    var matchingElements = [];
    var allElements = this.getElementsByTagName('*');
    for (var i = 0, n = allElements.length; i < n; i++)
    {
        if (allElements[i].getAttribute(attribute) !== null)
        {
            matchingElements.push(allElements[i]);
        }
    }
    return matchingElements;
};