Mi Libreria
by Lazaro Contreras
HTML
<textarea id="Text">Change Me!</textarea>
<button id="Demo">Click Me!</button>
JavaScript
function Id(id) {
var about = "Id Invalid";
if (id) {
if (window === this) {
return new Id(id);
}
this.e = document.getElementById(id);
this.getHtml = this.e.innerHTML;
this.getValue = this.e.value;
this.getId = this.e.id;
return this;
} else {
return about;
}
}
Id.prototype = {
click: function(callback) {
AddEvent(this.e,'click', callback, false);
return this;
},
hover: function(callback) {
AddEvent(this.e,'mouseenter', callback, false);
return this;
},
hoverOut: function(callback) {
AddEvent(this.e,'mouseout', callback, false);
return this;
},
hide: function () {
this.e.style.display = 'none';
return this;
},
show: function () {
this.e.style.display = 'inherit';
return this;
},
setBackground: function (background) {
this.e.style.background = background;
return this;
},
setId: function (newid) {
this.e.id = newid;
return this;
},
setValue: function (newval) {
this.e.value = newval;
return this;
},
setHtml: function (newhtml) {
this.e.innerHTML = newhtml;
return this;
},
toggle: function () {
if (this.e.style.display !== 'none') {
this.e.style.display = 'none';
} else {
this.e.style.display = '';
}
return this;
},
size: function (height, width) {
this.e.style.height = height + 'px';
this.e.style.width = width + 'px';
return this;
},
AddEvent: function(event, callback) {
AddEvent(this.e,event, callback, false);
return this;
},
RemEvent: function(event, callback) {
RemEvent(this.e,event, callback, false);
return this;
}
};
function Load(NameFunction){
return AddEvent(window,'load',NameFunction,false);
}
function TagName(tagName){
return document.getElementsByTagName(tagName);
}
function Create(Create){
return document.createElement(Create);
}
function Get(Element,Attribute){
return Element.getAttribute(Attribute);
}
function...