Set img src from an input box with jQuery
<p>I'm trying to set the <code>img src</code> based on the value of an input box with jQuery:</p>

<pre><code>&lt;img class="preview" id="img" src=""&gt;    
&lt;input id="form" placeholder="skin URL"&gt;    
</code></pre>

<p>This is the javascript code:</p>

<pre><code>$("#form").change(function(){
$("#img").attr("src", $("#form").val());
});
</code></pre>

<p>I don't know why is not working. What's wrong?</p>

<p>EDIT: Now it works but i set a cookie on the input box so when i refresh the page the img only loads when input box loses focus(with .blur()). I want the img to always load automatically. Any tips?</p>