javascript offsetWidth Undefined?
<p>I'm writing a plugin for a javascript libary to center elements both vertically and horizontally.</p>

<p>However whenever I try to get the offsetWidth or offsetHeight of an element I get back undefined.</p>

<p>Here's how's I'm getting the offsetWidth:</p>

<pre><code>this.offsetWidth;
</code></pre>

<p>but when i i use:</p>

<pre><code>getElementById().offsetWidth;
</code></pre>

<p>it works fine but i can't use that code i need it to work this way:</p>

<pre><code>this.offsetWidth;
</code></pre>

<p>code:</p>

<pre><code>center:function(){
this.css({position: "absolute"});
var screenW = screen.width;
var screenH = screen.height;
var elemW = this.offsetWidth;
alert(elemW);
alert(screenW);
},
</code></pre>

<p>does this help? this is my objective</p>

<pre><code>x$(elem).center();
</code></pre>

<p>so this would refer to to x$(elem)</p>
