Obtaining half the width of an image using Javascript
<p>I am trying to calculate half of the width of an object using Javascript. </p>

<pre><code>    var img = document.getElementById('picture1'); 
    var width = img.clientWidth;
    var halfwidth = width/2;  
</code></pre>

<p>I then need to plug that variable into a jquery css modifier for margin-left. This will be used to position the image in the exact center of the page. </p>

<pre><code>    $('#div').css('margin-left','-400px');
</code></pre>

<p>but instead of -400px, I need to have the          variable in there somehow. Can this be accomplished? </p>
