Jquery Live Preview in Text Area with function
<p>I have here my code that when i click a div it will insert to textarea and it will show its preview. The content that will be inserted in textarea is image but it doest show the image live instead it needs to type a character on textarea. </p>

<pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
&lt;script&gt;
$(document).ready(function() {
$('.image').click(function(e){
    var tav    = $('#image_code').val(),
        strPos = $('#image_code')[0].selectionStart;
        front  = (tav).substring(0,strPos),
        back   = (tav).substring(strPos,tav.length); 
        $('#image_code').val(front + '&lt;img src=\"' + $(this).attr("alt") + '\"&gt;' + back);
});
$('#image_code').keyup(function() {
   $('#image_preview').html( $(this).val() );
 });
});
&lt;/script&gt;

&lt;textarea id="image_code"&gt;&lt;/textarea&gt;
&lt;div id="image_preview"&gt;&lt;/div&gt;

&lt;div id="1" class="image" title="1" alt="http://xxxx.jpg"&gt;1&lt;/div&gt;
&lt;div id="2" class="image" title="2" alt="http://xxxx.jpg"&gt;2&lt;/div&gt;
&lt;div id="3" class="image" title="3" alt="http://xxxx.jpg"&gt;3&lt;/div&gt;
&lt;div id="4" class="image" title="4" alt="http://xxxx.jpg"&gt;4&lt;/div&gt;
&lt;div id="5" class="image" title="5" alt="http://xxxx.jpg"&gt;5&lt;/div&gt;
</code></pre>

<p>Please Help me. Thanks a lot!</p>
