Setting the style.maxWidth from a variable
<p>My cod is this:</p>

<pre><code>&lt;img src="img.png"&gt;

&lt;dd id="123"&gt;COMMENT&lt;/dd&gt;

&lt;script&gt;
var img = new Image();
img.onload = function () {
alert(this.width);
}
img.src = 'img.png';
&lt;/script&gt;
</code></pre>

<p>This alerts a window with width of an img.png. The question is: how to set this width value for an element I need.</p>

<p>Something like:</p>

<pre><code>document.getElementById('123').style.maxWidth = this.width;
</code></pre>

<p>Instead of:</p>

<pre><code>alert(this.width);
</code></pre>