var F = function(selector, context) {
    return this.init(selector, context);
};
F.prototype.init = function(selector, context) {
    var nodeList = (context || document).querySelectorAll(selector);
    this.length = nodeList.length;
    for (var i=0; i<this.length; i+=1) {
        this[i] = nodeList[i];    
    }
    return this;
};
F.prototype.each = function(fn) {
    var i=0, length = this.length;
    for (; i<length; i+=1) {
        fn.call(this[i], i, this[i]);
    }
    return this;
};

F.prototype.hide = function() {
    this.each(function() {
       this.style.display = "none";
    });
};

var $ = function(selector, context) {
    return new F(selector, context);
};

$("button")[0].onclick = function() {
    $("img").hide();  
};