if you want to write a library similar to jquery
see this good video
http://ejohn.org/blog/building-a-javascript-library/
You can write you jquery extensions as below
For example, I wrote the following a few days ago
jQuery.fn.centerElement = function () {
trace('trying to center');
this.css("position","relative");
var parentObj = $(this).parent();
this.css("top", ( parentObj.height() - this.height() ) / 2 + "px");
this.css("left", ( parentObj.width() - this.width() ) / 2 + "px");
return this;
};
you can use as below
$('#divid').centerElement();
source
share