var F = function(id) { return this.getElementById(id); }; F.prototype.getElementById = function(id) { this.element = document.getElementById(id); return this; }; F.prototype.hide = function() { this.element.style.display = "none"; }; document.getElementById("button").onclick = function() { new F("image1").hide(); new F("image2").hide(); };