Skip navigation

Monthly Archives: February 2012


You can see the power of jQuery plugin below. The following code will extend the jQuery $ and center whatever element you are selecting.

\\ 
jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}
 
//Use the above function as:
$(element).center();
\\

Note: Not tested in all browsers.


Neat piece of jQuery code to disable right click

\\ 
$(document).ready(function() {
    $(document).bind("contextmenu", function(e) {
        return false;
    });
});
\\ 
Follow

Get every new post delivered to your Inbox.

Join 150 other followers