$.fn.moveToCenter = function() {    //pobieramy szerokość i wysokość elementu    var elWidth = this.innerWidth(), elheight = this.innerHeight();     //umieszczamy element na środku    this.css({        position: 'absolute',        left: '50%',        top: '50%',        marginLeft: ((elWidth - 2 * elWidth) / 2) + 'px',   //obliczamy lewy margines        marginTop: ((elheight - 2 * elheight) / 2) + 'px',  //obliczamy prawy margines        marginBottom: 0,    //pozbywamy się dolnego marginesu, gdyby przypadkiem był ustawiony        marginRight: 0       //pozbywamy się prawego marginesu, gdyby przypadkiem był ustawiony    });     return this;} //po napisaniu funkcji, wywołujemy ją$(function() {    $('#container').moveToCenter();});
